算法训练——最长字符串

#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;
}

  

猜你喜欢

转载自www.cnblogs.com/Hqx-curiosity/p/12236683.html