Advertisement
Guest User

Untitled

a guest
May 25th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. int SmileCount = 0;
  7. int state = 0;
  8.  
  9. void move(char symbol)
  10. {
  11.     //cout << "state " << state << endl;
  12.     if (state == 0)
  13.     {
  14.         if (symbol == ';' || symbol == ':')
  15.         {
  16.             state = 1;
  17.             return;
  18.         }
  19.         state = 0;
  20.         return;
  21.     }
  22.  
  23.     if (state == 1)
  24.     {
  25.         if (symbol == ';' || symbol == ':' || symbol == '-')
  26.         {
  27.             state = 1;
  28.             return;
  29.         }
  30.         if (symbol == '(')
  31.         {
  32.             state = 2;
  33.             SmileCount++;
  34.             return;
  35.         }
  36.         if (symbol == ')')
  37.         {
  38.             state = 3;
  39.             SmileCount++;
  40.             return;
  41.         }
  42.         if (symbol == '[')
  43.         {
  44.             state = 4;
  45.             SmileCount++;
  46.             return;
  47.         }
  48.         if (symbol == ']')
  49.         {
  50.             state = 5;
  51.             SmileCount++;
  52.             return;
  53.         }
  54.         state = 0;
  55.         return;
  56.     }
  57.  
  58.     if (state == 2)
  59.     {
  60.         if (symbol == '(')
  61.         {
  62.             state = 2;
  63.             return;
  64.         }
  65.         if (symbol == ';' || symbol == ':')
  66.         {
  67.             state = 1;
  68.             return;
  69.         }
  70.         state = 0;
  71.         return;
  72.     }
  73.  
  74.     if (state == 3)
  75.     {
  76.         if (symbol == ')')
  77.         {
  78.             state = 3;
  79.             return;
  80.         }
  81.         if (symbol == ';' || symbol == ':')
  82.         {
  83.             state = 1;
  84.             return;
  85.         }
  86.         state = 0;
  87.         return;
  88.     }
  89.  
  90.     if (state == 4)
  91.     {
  92.         if (symbol == '[')
  93.         {
  94.             state = 4;
  95.             return;
  96.         }
  97.         if (symbol == ';' || symbol == ':')
  98.         {
  99.             state = 1;
  100.             return;
  101.         }
  102.         state = 0;
  103.         return;
  104.     }
  105.  
  106.     if (state == 5)
  107.     {
  108.         if (symbol == ']')
  109.         {
  110.             state = 5;
  111.             return;
  112.         }
  113.         if (symbol == ';' || symbol == ':')
  114.         {
  115.             state = 1;
  116.             return;
  117.         }
  118.         state = 0;
  119.         return;
  120.     }
  121.  
  122. }
  123.  
  124.  
  125. int main()
  126. {
  127.     char c[300];
  128.     cin.get(c, 200);
  129.     for (int i = 0; c[i] != '\0'; i++)
  130.     {
  131.         move(c[i]);
  132.     }
  133.     cout << SmileCount;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement