- import java.util.HashMap;
- public class test
- {
- public static void main(String args[]) throws Exception
- {
-
- HashMap<String,String> hm=new HashMap<String,String>();
- for(int i=65;i<91;i++)
- {
- hm.put(String.valueOf((char)i),String.valueOf(i));
- }
- Object obj[]=hm.keySet().toArray();
- int splitData=5; //按几个数据分
- int totalPage=obj.length/splitData; //能分多少段
- int remainder=obj.length%splitData; //还余多少个
- System.out.println(hm.getClass().getSimpleName()+"中共有("+obj.length+")个人.\n按每组("+splitData+")个人来分,可以分为("
- +totalPage+")组。剩余("+remainder+")个人。");
- for(int i=0;i<obj.length-splitData;i+=splitData)
- {
- for(int j=0;j<splitData;j++)
- {
- System.out.print(obj[i+j]);
- }
- System.out.println();
- }
- for(int i=0;i<remainder;i++) //取出剩余的
- {
- System.out.print((i!=remainder-1)?(String)obj[totalPage+i]:(String)obj[totalPage+i]+"(啊哦,好像剩我"+remainder+"个了,求组团啊)");
- }
-
-
- }
- }
复制代码 |