• 软件测试作业2


     1 public class main {
     2 
     3     /**
     4      * @param args
     5      */
     6     public static void main(String[] args) {
     7         // TODO Auto-generated method stub
     8             text a = new text();
     9             a.run();
    10             text2 b = new text2();
    11             b.run();
    12     }
    13 
    14 }
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    
    
    public class text {
    
        /**
         * @param args
         */
        public void run(){
            // TODO Auto-generated method stub
                //String a = "Hello World My First Unit Test";
                Scanner stdin = new Scanner(System.in); 
                System.out.println("请输入:");
                String a = stdin.nextLine();
                String[] b = a.split(" ");
                Map map = new HashMap<String,Integer>();       
                for(int c = 0;c<b.length;c++)
                {
                    if(map.containsKey(b[c]))
                    {
                        int d = (Integer)map.get(b[c]);
                        map.put(b[c],d+1);
                    }
                    else
                    {
                        map.put(b[c],1);
                    }
                }
                for(Object obj : map.keySet()){
    
                    Object value = map.get(obj );
    
                    }
    
    
                for(Object obj : map.keySet())
                {
                    System.out.println(obj.toString()+"出现了"+map.get(obj)+"次");
    
                }
    
    
        }
    
    }
     1 import java.util.HashMap;
     2 import java.util.Map;
     3 import java.util.Scanner;
     4 
     5 
     6 public class text2 {
     7 
     8     /**
     9      * @param args
    10      */
    11     public void run(){
    12         // TODO Auto-generated mrethod stub
    13         //String a = "how are you";
    14         Scanner stdin = new Scanner(System.in); 
    15         System.out.println("请输入:");
    16         String a = stdin.nextLine();
    17 
    18         String[] b = a.split(" ");
    19         StringBuffer c = new StringBuffer();
    20         for(int d=b.length-1;d>=0;d--)
    21         {
    22             c.append(b[d]+" ");
    23         }
    24         System.out.println(c);
    25         
    26     }
    27 
    28 }

  • 相关阅读:
    计算机故障
    线程池&进程池
    机箱-网卡-声卡-显卡-显示器
    scrapy请求传参-BOSS反爬
    计算机硬件-主板
    计算机硬件-内存
    计算机硬件-硬盘
    计算机硬件-CPU
    ZJNU 1223
    ZJNU 1217
  • 原文地址:https://www.cnblogs.com/longxiangyuwai/p/5319930.html
Copyright © 2020-2023  润新知