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);
                }
            }
        }
  • 相关阅读:
    位图索引(Bitmap Index)的故事
    Oracle 用户管理
    Linux中hosts文件的修改
    oracle 错误码 ORA-00119 / ORA-00130
    Oracle 外键约束
    Oracle Basic Ready Notes
    SQL语句Tips
    AWK 简明教程
    JObject对json的操作
    C#Stopwatch的使用,性能测试
  • 原文地址:https://www.cnblogs.com/ustc-anmin/p/12615144.html
Copyright © 2011-2022 走看看