找最大的字符串

找最大的字符串

/problem-sets/1336948160465235968/problems/1336959055090184194

又不检测我,那直接用库函数了(坏学生?!ε=ε=ε=┏(゜ロ゜;)┛)

strcmp函数可以比较字符串(a,b比较 小-1,等0,大1)
strcpy函数可以复制字符串(或者说是字符串赋值)

#include<stdio.h>
#include<string.h>//字符串库函数
int main(void) 
{
	char max[10]={0};
	char str[10];
	int i;
	for(i=0;i<5;i++)
	{
		gets(str);
		if(strcmp(str,max)>0)
		strcpy(max,str);
	}
	printf("Max is: %s",max);
	return 0;
}
posted @ 2020-12-18 23:58  summeriver13  阅读(50)  评论(0)    收藏  举报