程序:

 1 #include<stdio.h>
 2 #include<string.h>
 3 #define N 81
 4 
 5 int main() {
 6     char ch[N],temp[N];
 7     int i,cnt,lng=0;
 8     scanf("%d",&cnt);
 9     gets(ch);
10     strcpy(temp,ch);
11     for(i=0; i<cnt; i++) {
12         gets(ch);
13         if(strlen(ch)>lng) {
14             lng = strlen(ch);
15             strcpy(temp,ch);
16         }
17     }
18     printf("The longest is: %s",temp);
19 }

 分析:

1、用两个一维数组即可

2、字符串之间复制用strcpy()

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
猜你喜欢
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
相关资源
相似解决方案