Untitled
#include <bits/stdc++.h> using namespace std; void De_lesseps() { string s; getline(cin, s); int n = s.size(); int cnt = 0; for (int i = 0; i < n; i++) { while (i < n && s[i] != ' ') i++; while (i < n and (s[i] == ' ' || s[i] == '.' || s[i] == '!' || s[i] == '?' || s[i] == ',')) i++; cnt++; } cout << cnt << '\n'; } int main() { ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int t{1}; while (t--) { De_lesseps(); } return 0; }
Leave a Comment