當前位置:編程學習大全網 - 編程軟體 - 編程輸入列表

編程輸入列表

# include & ltstdio.h & gt

# include & ltstring.h & gt

int main()

{

char string[10][50],temp[50];

Printf("請輸入6個字:\ n ");

for(int I = 0;我& lt6;i++)

scanf("%s ",string[I]);

/*冒泡排序*/

for(int I = 0;我& lt5;i++)

for(int j = I+1;j & lt6;j++)

如果(strcmp (string [I],string[j])= = 1)//比較字符串大小,可以使用strcmp。

{

strcpy(temp,string[I]);//交換strcpy

strcpy(string[i],string[j]);

strcpy(string[j],temp);

}

//輸出

Printf("按順序輸出6個字:\ n ");

for(int I = 0;我& lt6;i++)

puts(string[I]);

返回0;

}

PS:不懂可以問。

  • 上一篇:學習Java!!!
  • 下一篇:山西應用科技學院機器人工程專業介紹
  • copyright 2024編程學習大全網