Дата активности | Консольный раздел | Прогресс | ||
---|---|---|---|---|
2021-05-19 | book | 000. Строки | 100 % | |
2021-05-19 | book | 001. Числа | 100 % | |
2021-05-19 | book | 010. Условия | 88 % | |
Итого: | 96 % |
C++ // 100%
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
string a;
int c=0, max;
getline(cin, a);
stringstream ss(a);
string word;
while (ss >> word){
c++;
}
string *b=new string[c];
stringstream bs(a);
for(int i=0; i<c; i++){
while(bs >> b[i]){
break;
}
}
int *len=new int[c];
for(int i=0; i<c; i++){
len[i]=b[i].length();
for(int j=0; j<b[i].length(); j++){
if(b[i][j]==',' || b[i][j]=='!' || b[i][j]=='.' || b[i][j]=='?' || b[i][j]=='-'){
len[i]--;
break;
}
max=len[0];
}
}
for(int i=0; i<c; i++){
if(max < len[i]){
max=len[i];
}
}
cout <<max<<endl;
delete[] b;
delete[] len;
return 0;
}