找最大的字符串
找最大的字符串
/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;
}
浙公网安备 33010602011771号