• HW-文件恢复-测试300


    //package t0817;
    import java.util.*;
    public class FileRelive {//类名换成Main
        public static void main(String[] args){
          // System.out.println("请按要求输入一组指令,换行输入:");
            Scanner Src= new Scanner(System.in);
            Vector<String> vec=new Vector<String>();
            int count=0;
            String str = "";
            while(Src.hasNextLine()){
                str=Src.nextLine();
                if(str.equals(""))break;
                vec.add(str);      // 入队
                count++;
            }    
            for(int i=0;i<count;i++){            
                System.out.println(FileLiveExe(vec.elementAt(i)));
            }        
        }
        static String[] commands = {"reset","reset board","board add","board delet","reboot backplane","backplane abort"};
        static String[] result = {"reset what","board fault","where to add","no board at all","impossible","install first"};
        public static String FileLiveExe(String str1){
            String strout="";
            String str2[]=str1.split(" ");  //空格分开的
            if(str2.length==1){              //长度为1时
                if(commands[0].startsWith(str2[0]))   //匹配第一个命令
                   strout=result[0] ;
                 else {
                      for(int i=1;i<commands.length;i++){  //匹配后面几个命令
                          if(commands[i].startsWith(str1)){
                              strout="unkown command";
                              break;
                          }
                      }
                      if(strout=="")                 // 都不匹配
                          strout="unkown command";
                      
                     }
            }else if(str2.length==2){
                int flag=0;    //找到啊标志位
                int index=-1;  //保存命令行数
                for(int j=1;j<commands.length;j++){
                    String temp[]=commands[j].split(" ");//空格先分隔一下命令
                    if(temp[0].startsWith(str2[0]) && temp[1].startsWith(str2[1])){ //如果两个分别匹配
                        index=j;
                        flag++;
                    }
                }
                if(flag==1) {strout=result[index];}  //赋值
                else strout="unkown command";
                
            }else{
                strout="unkown command";
            }        
            return strout;
        }
        
    
    }
  • 相关阅读:
    php中global和$GLOBALS[]的分析之一
    javascript 标签 src 链接动态文件。
    Allegro基本操作——PCB布线
    AMD单桥主板上电时序的详细解释
    AMD单双桥时序简叙
    AMD移动FP5平台时序解释
    orcad元件属性批量修改(通过excel表格)
    加减乘除基本函数
    1.excel如何让一列的数都乘以固定值
    ORCAD元件属性白色区域和黄色区域的理解
  • 原文地址:https://www.cnblogs.com/snowwhite/p/4738465.html
Copyright © 2020-2023  润新知