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);
                }
            }
        }
  • 相关阅读:
    基本的Web控件二
    基本的Web控件一
    centos更改默认语言
    nginx优化配置
    使用nginx的proxy_cache做网站缓存
    centos7配置笔记
    redis批量删除
    Linq常用操作
    MVC ViewData和ViewBag[转]
    Transact-SQL的除法问题
  • 原文地址:https://www.cnblogs.com/ustc-anmin/p/12615144.html
Copyright © 2011-2022 走看看