• 软件测试作业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 }

  • 相关阅读:
    js去前后空格
    IE7以上支持Fiddler 监听本地
    IE8 scriptX print 无法使用的bug
    那些相见恨晚的 JavaScript 技巧
    oracle sql
    JS人民币金额转大写程序
    div自适应高度
    .NET Remoting 使用最佳实践,(部分翻译)
    对DataTable 进行Distinct操作
    用财富的眼光看知识管理
  • 原文地址:https://www.cnblogs.com/longxiangyuwai/p/5319930.html
Copyright © 2020-2023  润新知