Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 3) Кол-во слов и самое длинное
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- const int N = 100000;
- char S[N];
- char z[N];
- cin.getline(S, N);
- char* ps = S;
- char* pz = z;
- int max = 0, t = 0, kol = 0;
- for (; *ps; ps++)
- {
- if (*ps != ' ' && *(ps + 1) == ' ' || *ps != ' ' && *(ps + 1) == '\0')
- {
- kol++;
- }
- if (*ps != ' ')
- {
- t++;
- if (t > max)
- {
- max = t;
- }
- }
- else
- {
- t = 0;
- }
- }
- cout << "max: " << max << endl;
- cout << "kol: " << kol << endl;
- }
Add Comment
Please, Sign In to add comment