Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string sentence;
- getline( cin, sentence);
- int circle = 0, square = 0, figure = 0;
- for (int i = 0; i < sentence.size(); i++)
- {
- if ( circle >= 0 && square >= 0 && figure >= 0) {
- switch (sentence[i]) {
- case '(':
- circle++;
- break;
- case '[':
- square++;
- break;
- case '{':
- figure++;
- break;
- case ')':
- circle--;
- break;
- case ']':
- square--;
- break;
- case '}':
- figure--;
- break;
- default:
- break;
- }
- }
- else
- {
- break;
- }
- }
- if ((circle == 0) && (square == 0) && (figure == 0))
- {
- cout << " All right!\n";
- }
- else
- {
- cout << " Mistake!\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement