#include <stdio.h>
int main(int argc, const char * argv[])
{
char arr[50];
//提示用户输入
int i = 0;
printf("请输入:\n");
while (1)
{
scanf("%c",&arr[i]);
if (arr[i]=='\n') {
break;
}
i++;
}
int _index = 0,count = 0,num = 0;//用于记录下标 长度
for (int i = 0; i != '\n'; i++)
{
//下面的数子65 90 97 122 是字母a z A Z 对应的ASCII码
if ((arr[i] >=65 &&arr[i]<=90) || (arr[i] >=97 &&arr[i]<=122))
{
count++;
}
else //if(arr[i]==' ')
{
if(count > num)
{
num = count;
_index = i;
}
count = 0;
}
}
for (int i = _index - num; i < _index ; i++)
{
printf("%c",arr[i]);
}
printf("\n");
return 0;
}
|