當前位置:編程學習大全網 - 編程軟體 - 編程輸入十個字符串。

編程輸入十個字符串。

#包含?" stdio.h "

#包含?" string.h "

int?主()

{

?夏爾?str[10][30]= { 0 };

?夏爾?tem[30]= { 0 };

?int?I,j;

?Printf("請輸入10字:");?

?for(I = 0;我& lt10;I++)//輸入

?scanf("%s ",str[I]);

?for(I = 0;我& lt9;I++)//排序

for(j = I+1;j & lt10;j++)

if(strcmp(str[i],str[j])& gt;0)

{

?strcpy(tem,str[I]);

?strcpy(str[i],str[j]);

?strcpy(str[j],tem);

}

?Printf("這10個單詞按字典排序,輸出為:\ n ");

?for(I = 0;我& lt10;i++)//?輸出

?{

?printf("%s\n ",str[I]);

?}

}

  • 上一篇:初中生學it學的會嗎?
  • 下一篇:單片機編程,實驗
  • copyright 2024編程學習大全網