Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int SmileCount = 0;
- int state = 0;
- void move(char symbol)
- {
- //cout << "state " << state << endl;
- if (state == 0)
- {
- if (symbol == ';' || symbol == ':')
- {
- state = 1;
- return;
- }
- state = 0;
- return;
- }
- if (state == 1)
- {
- if (symbol == ';' || symbol == ':' || symbol == '-')
- {
- state = 1;
- return;
- }
- if (symbol == '(')
- {
- state = 2;
- SmileCount++;
- return;
- }
- if (symbol == ')')
- {
- state = 3;
- SmileCount++;
- return;
- }
- if (symbol == '[')
- {
- state = 4;
- SmileCount++;
- return;
- }
- if (symbol == ']')
- {
- state = 5;
- SmileCount++;
- return;
- }
- state = 0;
- return;
- }
- if (state == 2)
- {
- if (symbol == '(')
- {
- state = 2;
- return;
- }
- if (symbol == ';' || symbol == ':')
- {
- state = 1;
- return;
- }
- state = 0;
- return;
- }
- if (state == 3)
- {
- if (symbol == ')')
- {
- state = 3;
- return;
- }
- if (symbol == ';' || symbol == ':')
- {
- state = 1;
- return;
- }
- state = 0;
- return;
- }
- if (state == 4)
- {
- if (symbol == '[')
- {
- state = 4;
- return;
- }
- if (symbol == ';' || symbol == ':')
- {
- state = 1;
- return;
- }
- state = 0;
- return;
- }
- if (state == 5)
- {
- if (symbol == ']')
- {
- state = 5;
- return;
- }
- if (symbol == ';' || symbol == ':')
- {
- state = 1;
- return;
- }
- state = 0;
- return;
- }
- }
- int main()
- {
- char c[300];
- cin.get(c, 200);
- for (int i = 0; c[i] != '\0'; i++)
- {
- move(c[i]);
- }
- cout << SmileCount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement