Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
/* QUANG VIPPRO */
#include <bits/stdc++.h>
using namespace std;
string s;
int res, cnt;
int main(){
getline(cin, s);
for(int i = 0; i < s.size(); i++){
if(s[i] >= 'A' and s[i] <= 'z'){
cnt++;
res = max(res, cnt);
}
if(s[i] == ' ')cnt = 0;
}
cout << res;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <iostream>
using namespace std;
int main() {
freopen("LWORD.INP","r",stdin);
freopen("LWORD.OUT","w",stdout);
int ans=0;
string s;
getline(cin,s);
s+=' ';
string t="";
for (char i:s) {
if (i==' ') {
ans = max(ans, int(t.size()));
t="";
} else {
t+=i;
}
}
cout << ans;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
1
136
0
tớ cảm ơn ạ