- 最长单词2
出于某些原因
- @ 2025-11-14 18:18:56
somehow这个代码没法判定x为空格
if(x==' ')
完整版
#include<bits/stdc++.h>
using namespace std;
int main(){
char x=' ';
string s="",curs="";
int maxl=-1,curl=0;
while(1){
cin>>x;
if(x==' '||x=='.'){
cout<<"end of one word\n";
printf("length %d\n",curl);
if(curl>maxl){
cout<<"bigger\n";
maxl=curl;
s=curs;
}
curs="a";
curl=0;
}
else {
curl++;
curs+=x;
}
if(x=='.')break;
}
for(int i=0;i<maxl;i++){
cout<<s[i];
}
return 0;
}
0 comments
No comments so far...
Information
- ID
- 635
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 98
- Accepted
- 39
- Uploaded By