-
Notifications
You must be signed in to change notification settings - Fork 0
/
P43.cpp
44 lines (38 loc) · 836 Bytes
/
P43.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
char exp;
int x=0,y=0,z=0,m=0,n=0,p=0;
vector<char>expr;
while(cin>>exp){
expr.push_back(exp);
}
for(int i=0;i<=expr.size();i++){
//cout<<expr[i];
if(expr[i]=='('){
x++;
}
if(expr[i]==')'){
y++;
}
if(expr[i]=='['){
z++;
}
if(expr[i]==']'){
m++;
}
if(expr[i]=='{'){
n++;
}
if(expr[i]=='}'){
p++;
}
}
//cout<<x<<' '<<y<<' '<<z<<' '<<m<<' '<<n<<' '<<p<<' ';
if(x==y&&z==m&&n==p){cout<<1;}else{cout<<0;}
}