Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <algorithm>
- int main()
- {
- setlocale(LC_ALL, "Rus");
- int variable;
- std::ifstream input("input.txt");
- std::string line;
- int n = 0;
- while (std::getline(input, line))
- {
- std::for_each(line.begin(), line.end(), [&n](const char &c)
- {
- if (c == '(') n++;
- if (c == ')') n--;
- }
- );
- }
- if (n == 0) std::cout << " verno" << std::endl;
- else
- {
- std::cout << "ne verno" << std::endl;
- if (n > 0)
- {
- std::cout << " Не хватает " << n << " закрывающих скобок(скобки)";
- }
- if (n < 0) {
- std::cout << " Не хватает " << abs(n) << " открывающих скобок(скобки)";
- }
- }
- input.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement