⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delimitermatch.java~14~

📁 符号匹配
💻 JAVA~14~
字号:
import java.io.*;
import java.util.*;
public class DelimiterMatch {
    Stack stack = new Stack();
    public void Matching()throws IOException{
        String s = " ";char temp,next;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            s = br.readLine();
        }catch(IOException e){
        }
        for(int i=0;i<s.length();i++){
            temp=s.charAt(i);
            if(temp =='('||temp == '['){
                stack.push(i);
                stack.push(temp);
            }
            if(temp == ')'&&stack.isEmpty())
                System.out.println("不匹配信息为:  ) in colum "+i+" is not matching");
            if(temp == ']'&&stack.isEmpty())
                System.out.println("不匹配信息为:  ] in colum "+i+" is not matching");
            if(temp == ')'&&!stack.isEmpty()){
                next = (Character) stack.pop();
                int m = (Integer) stack.pop();
                if(next == '(')continue;
                //else if(stack.isEmpty())
                 // System.out.println("不匹配信息为:  ) in colum "+i+" is not matching");
                else
                System.out.println("不匹配信息为: "+next+" in colum "+ m +" is not matching with ) in colum "+i);
            }
            if(temp == ']'&&!stack.isEmpty()){
                next = (Character) stack.pop();
                int m = (Integer) stack.pop();
                if(next == '[')continue;
               // else if(stack.isEmpty())
                //  System.out.println("不匹配信息为:  ] in colum "+i+" is not matching");
                else
                System.out.println("不匹配信息为: "+next+" in colum "+ m +" is not matching with ] in colum "+i);
            }
            else if(temp!='('&& temp!='[')
             continue;
        }
        }
    public static void main(String[] args)throws IOException {
        DelimiterMatch delimitermatch = new DelimiterMatch();
        delimitermatch.Matching();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -