Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- cout << "you can enter 20 symbols" << endl;
- char a[21];
- cin.getline(a,21);
- cout << "these symbols take part in the test" << endl;
- cout << a << endl;
- int letters, gaps, word, b, num;
- letters = 0;
- gaps = 0 ;
- word = 0;
- b = 0;
- num = strlen (a);
- while ( b < num)
- {
- if (b + 1 == num and a[b] == ' ')
- {
- break;
- }
- if ( a[b] != ' ')
- {
- b++;
- letters++;
- }
- if ( a[b] == ' ')
- {
- b++;
- gaps++;
- }
- }
- b=0;
- while ( b < num)
- {
- if ( a[b] != ' ' )
- {
- while ( a[b] != ' ' )
- {
- b++;
- }
- word++;
- }
- b++;
- }
- cout << "these symbols have " << word << " words" ;
- cout << endl << letters << " letters" ;
- cout << endl << gaps << " gaps";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement