zoukankan      html  css  js  c++  java
  • test

    public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNextLine()) {
                String input = scanner.nextLine();
                if (input == null || input.length() == 0) {
                    System.out.println(0);
                    continue;
                }
                boolean nextIsChar = true;
                boolean nextIsCommand = false;
                boolean onlyNOTCommand = false;
                boolean flag = true;
                String[] element = input.split(" ");
                for (String temp : element) {
                    if (temp.length() == 1 && (Character.isLowerCase(temp.charAt(0)))) {
                        if (nextIsChar) {
                            nextIsChar = false;
                            nextIsCommand = true;
                            onlyNOTCommand = false;
                            continue;
                        } else {
                            System.out.println(0);
                            flag = false;
                            break;
                        }
                    } else if (temp.length() > 1) {
                        if (nextIsCommand) {
                            if (!onlyNOTCommand && temp.equals("AND")) {
                                nextIsChar = true;
                                nextIsCommand = false;
                                continue;
                            } else if (!onlyNOTCommand && temp.equals("OR")) {
                                nextIsChar = true;
                                onlyNOTCommand = true;
                                continue;
                            } else if (temp.equals("NOT")) {
                                nextIsChar = true;
                                nextIsCommand = false;
                                onlyNOTCommand = false;
                                continue;
                            } else {
                                System.out.println(0);
                                flag = false;
                                break;
                            }
                        } else {
                            System.out.println(0);
                            flag = false;
                            break;
                        }
    
                    }
                    flag = false;
                    System.out.println(0);
                    break;
                }
                if (flag) {
                    System.out.println(1);
                }
            }
        }
  • 相关阅读:
    2019武汉大学数学专业考研真题(回忆版)
    矩阵求导与投影梯度相关问题
    Coxeter积分计算
    常微分方程
    一些个人偏好的书籍
    Angular的表单组件
    Angular的第一个组件
    Angular的第一个helloworld
    Angular入门
    handlebars——另外一个模板引擎
  • 原文地址:https://www.cnblogs.com/ustc-anmin/p/12615144.html
Copyright © 2011-2022 走看看