#定義N 5
使用命名空間std
int main()
{
int i,j,n = N
char str[N][80]={ "英語","數學","計算機","物理","數據庫" };
char mystring[80];
//字符串排序
for(I = 0;我& ltn;i++)
{
for(j = I;j & ltn;j++)
{
if(strcmp(str[i],str[j])& gt;0)
{
strcpy(mystring,str[I]);
strcpy(str[i],str[j]);
strcpy(str[j],mystring);
}
}
}
//輸出排序後的字符串。
cout & lt& lt"排序的字符串:" & lt& ltendl
for(I = 0;我& ltn;i++)
cout & lt& ltstr[I]& lt;& ltendl
返回0;
}