Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string>
- #include <iostream>
- using namespace std;
- int main(void) {
- string Str;
- cin >> Str;
- int k = 0, counter1 = 0, counter2 = 0, counter3 = 0, counter4 = 0;
- int s = Str.size();
- while(s > 0)
- {
- char c = Str[Str.size() - s];
- if(c == 40) // ( )
- {
- counter1++;
- }
- else
- {
- if(c == 41)
- {
- if(counter1 > 0)
- {
- counter1--;
- }
- else
- {
- printf("Dizbalance.\n");
- return 0;
- }
- }
- }
- ///
- if(c == 91) // 91 - символ '[', 93 - ']'
- {
- counter2++;
- }
- else
- {
- if(c == 93)
- {
- if(counter2 > 0)
- {
- counter2--;
- }
- else
- {
- printf("Dizbalance.\n");
- return 0;
- }
- }
- }
- //
- if(c == 60) // 60 - символ '<', 62 - '>'
- {
- counter3++;
- }
- else
- {
- if(c == 62)
- {
- if(counter3 > 0)
- {
- counter3--;
- }
- else
- {
- printf("Dizbalance.\n");
- return 0;
- }
- }
- }
- ///
- if(c == 123) // 123 - символ '{', 125 - '}'
- {
- counter4++;
- }
- else
- {
- if(c == 125)
- {
- if(counter4 > 0)
- {
- counter4--;
- }
- else
- {
- printf("Dizbalance.\n");
- return 0;
- }
- }
- }
- s--;
- }
- if(counter1 == 0 && counter2 == 0 && counter3 == 0 && counter4 == 0) printf("Balance\n");
- else printf("Dizbalance");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement