Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
26874 唐心 最长的单词 C++ Accepted 1 MS 704 KB 568 2022-05-24 17:19:38

Tests(1/1):


Code:

#include<iostream> #include<cmath> #include<cstdio> #include<cstring> using namespace std; int main() //主函数入口 { char str[200] = {0}; int i=0,index,max = 0,num=0; cin.getline(str,200); while(str[i]!='\0') { if(str[i]==' ') { if(num>max) { max = num; index = i; } num = 0; } else num++; i++; } if(num>max) { max = num; index = i; } index = index-max; for(i=0;i<max;i++) cout<<str[index+i]; cout<<endl; return 0; //结束整个程序 }