Misha_

Задача - "Смайлики"

Oct 17th, 2018
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cctype>
  4. using namespace std;
  5.  
  6. int main() {
  7.     char S[100000] = {};
  8.     cin.getline(S, 100000);
  9.     int size = strlen(S), count = 0;
  10.     bool eyes, mouth;
  11.     for (int i = 0; i < size;) {
  12.         eyes = false;
  13.         mouth = false;
  14.         if (S[i] == ';' || S[i] == ':') {
  15.             eyes = true;
  16.             ++i;
  17.             if (S[i] == '-') {
  18.                 while (S[i] == '-') {
  19.                     ++i;
  20.                 }
  21.                 if (S[i] == ')' || S[i] == '(' || S[i] == ']' || S[i] == '[') {
  22.                     mouth = true;
  23.                     while (S[i] == ')' || S[i] == '(' || S[i] == ']' || S[i] == '[') {
  24.                         ++i;
  25.                     }
  26.                 }
  27.             }
  28.             else {
  29.                 if (S[i] == ')' || S[i] == '(' || S[i] == ']' || S[i] == '[') {
  30.                     mouth = true;
  31.                     while (S[i] == ')' || S[i] == '(' || S[i] == ']' || S[i] == '[') {
  32.                         ++i;
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.         else {
  38.             ++i;
  39.         }
  40.         if (eyes && mouth)
  41.             ++count;
  42.     }
  43.     cout << count;
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment