TheRasVa

Задача 5,6

Mar 29th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4. char mas[100000];
  5.  
  6.  
  7. int main()
  8. {
  9.     int n, i = 0, chr=0;
  10.     setlocale(LC_ALL, "russian");
  11.     cout << "Введите количество СКОБОЧЕК{}: ";
  12.     cin >> n;
  13.     cout << "Введите СКОБОЧКИИИ{}: ";
  14.     while (i < n)
  15.     {
  16.         cin >> mas[i];
  17.         i++;
  18.     }
  19.     i = 0;
  20.     while (i < 100)
  21.     {
  22.         if (mas[i] == '{')
  23.         {
  24.             chr++;
  25.         }
  26.         else if (mas[i] == '}')
  27.         {
  28.             chr--;
  29.         }
  30.         i++;
  31.         if (chr < 0)
  32.         {
  33.             cout << "Скобки расставлены НЕПРАВИЛЬНО!!11адынадын" << endl;
  34.             system("pause");
  35.             return 0;
  36.         }
  37.     }
  38.     if (chr == 0)
  39.     {
  40.         cout << "Скобки расставлены правильно.";
  41.     }
  42.     else
  43.     {
  44.         cout << "Скобки расставлены НЕПРАВИЛЬНО!!11адынадын";
  45.     }
  46.     cout << endl;
  47.     system("pause");
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment