Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int q = 0;
- int slovo = 0;
- int number = 0;
- char x;
- ifstream f("text.txt");
- while (f.peek() != EOF)
- {
- f.get(x);
- switch (q)
- {
- case 0: {
- if ((x >= 'a' && x <= 'z'))
- {
- slovo++;
- q = 1;
- }
- else {
- if (x >= '0' && x <= '9')
- {
- q = 2;
- number++;
- }
- else
- {
- if (x != ' ')
- q = 3;
- }
- }
- break;
- }
- case 1: {
- if (!((x >= 'a' && x <= 'z')))
- if (x != ' ')
- {
- slovo--;
- q = 3;
- }
- else q = 0;
- cout << x;
- break;
- }
- case 2: {
- if (!(x >= '0' && x <= '9'))
- if (x != ' ')
- {
- number--;
- q = 3;
- }
- else
- q = 0;
- cout << x;
- break;
- }
- case 3: {
- if (x == ' ')
- q = 0;
- cout << x;
- break;
- }
- }
- }
- cout << "Number = " << number << endl;
- cout << "slov= " << slovo << endl;
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment