package demoSix;
import java.io.IOException;
/*
*@author:张文波
*@time2020年4月20日下午9:44:20
*/
//利用堆栈实现括号的匹配
public class KuoHaoPipei
{
//思路用StringBuffer的append在尾部添加,
public static void main(String[] args) throws IOException
{
char s=(char) System.in.read();
StringBuffer bs=new StringBuffer();
while((s)!='~'){
bs.append(s);
s=(char) System.in.read();
}
int count=0;
String str=new String(bs);
for(int i=0;i<str.length();i++) {
if(str.charAt(i)=='(') {
count++;
}
else if(str.charAt(i)==')') {
count--;
}
}
if(count>0) {
System.out.println("缺少右括号");
}else if(count<0) {
System.out.println("缺少左括号");
}else if(count==0) {
System.out.println("哇偶,成双成对!");
}
}
}