算法训练——最长字符串

 

 

#include<stdio.h>
#include<string.h>
int main(){
	int a[5],i,max;
	char str[5][100];
	for(i=0;i<5;i++){
		scanf("%s",str[i]);
		a[i] = strlen(str[i]);
	}
	for(i=0;i<5;i++){
		if(a[i] > a[max]){
			max = i;
		}
	}
	printf("%s",str[max]);
	return 0;
}

  

posted @ 2020-01-27 19:47  Hqx_curiosity  阅读(197)  评论(0)    收藏  举报