学生


私信TA

用户名:2544020292

访问量:47

签 名:

等  级
排  名 5071
经  验 1531
参赛次数 0
文章发表 1
年  龄 0
在职情况 学生
学  校 吉林农业大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

import java.util.*;


public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int[] a=new int[11];

a[0]=2;

a[1]=0;

a[2]=3;

a[3]=4;

a[4]=5;

a[5]=6;

a[6]=7;

a[7]=8;

a[8]=9;

a[9]=10;

a[10]=0;

String[] b=new String[11];

         for(int i=0;i<11;i++){

             b[i]="";  

           } 

         

           

LinkedList<String> input=new LinkedList<>();

while (scanner.hasNext()) {

String inputstr = scanner.nextLine();

input.add(inputstr);

// System.out.println(c);

}

for(String A:input){

    String[] A2line=A.split(" ");

    if(A.substring(0,2).equals("in")){

      //System.out.println( A.substring(0,2) );

      //System.out.println( a[Integer.parseInt(A2line[1])-1]);

      if(b[Integer.parseInt(A2line[1])+1].equals("")){

              int temp=0;

              temp=a[Integer.parseInt(A2line[1])+1];

              a[Integer.parseInt(A2line[1])+1]=a[0];

              a[0]=temp;

              int temp2=a[Integer.parseInt(A2line[1])];

              a[Integer.parseInt(A2line[1])]= a[Integer.parseInt(A2line[1])+1];

                      a[Integer.parseInt(A2line[1])+1]=temp2;

                      b[Integer.parseInt(A2line[1])+1]=A2line[2];

        }else{

                            int temp=0;

              temp=a[Integer.parseInt(A2line[1])-1];

              a[Integer.parseInt(A2line[1])-1]=a[11-Integer.parseInt(A2line[1])];

              a[11-Integer.parseInt(A2line[1])]=temp;

              int temp2=a[11-Integer.parseInt(A2line[1])];

              a[11-Integer.parseInt(A2line[1])]= a[Integer.parseInt(A2line[1])];

                      a[Integer.parseInt(A2line[1])]=temp2;

                      b[11-Integer.parseInt(A2line[1])]=A2line[2];

        }

             

    }else if (A.substring(0,2).equals("sh")){

        //  System.out.println( A.substring(0,2) ); 

           for(int i=0;i<11;i++){

               if(!b[i].equals("")){

             //System.out.println(b[i]); 

             String space="";

             for(int m=0;m<8-b[i].length();m++){

                 space+=" ";

             }

               if(a[i]>9){

               System.out.println(b[i]+space+a[i]) ; 

              }else if (a[i]<=9){       

               System.out.println(b[i]+space+" "+a[i]) ; 

              }

              


               }else{ 

              if(a[i]>9){

                 System.out.println("        "+a[i]);

              }else if (a[i]<=9){       

              System.out.println("          "+a[i]);

              }

                  

              }

           }

           

         System.out.println("********************");    

    }else if (A.substring(0,2).equals("se")){

            for(int i=0;i<11;i++){

        if(b[i].equals(A2line[1])){

           System.out.println(a[i]-1); 

             }

                

            }

            System.out.println("********************");    

    }


    





}


}

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区