欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: C語言程序:輸入五個國家的名稱按字母順序排列輸出 [打印本頁]

作者: v家的閨女vjibn    時間: 2016-5-8 21:01
標題: C語言程序:輸入五個國家的名稱按字母順序排列輸出
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5.         char cs [5][20];
  6.         char st[20];
  7.         int i,j,p;
  8.     printf("input country's name:\n");
  9.         for(i=0;i<5;i++);
  10.         gets(cs[i]);
  11.         printf("\n");
  12.         for(i=0;i<5;i++)
  13.         {
  14.                 p=i;strcpy(st,cs[i]);
  15.                 for(j=i+1;j<5;j++)
  16.                 {
  17.                         if(strcmp(cs[i],st)<0)
  18.                         {p=j;strcpy(st,cs[j]);}
  19.                 if(p!=1)
  20.                 {   strcpy(st,cs[i]);
  21.                     strcpy(cs[i],cs[p]);
  22.                         strcpy(cs[p],st);


  23.                 }
  24.          puts(cs[i]);               
  25.         
  26.                 }
  27.         printf("\n");
  28.         
  29.         }
  30. }
復制代碼





歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1