标题:大家看看怎么出问题了??怎么改啊!
取消只看楼主
johnliu6
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-19
结帖率:0
已结贴  问题点数:20 回复次数:0 
大家看看怎么出问题了??怎么改啊!
import java.util.*;
import java.util.Scanner;
class RandomGroup
{
public static void main(String[] args)
{
LinkedList<Integer> l=new LinkedList<Integer>();
int[][] group=new int[5][8];
Random r=new Random();
    Scanner input=new Scanner(System.in);
for(int i=0;i<40;i++)
  l.add(new Integer(i+1));
for(int i=0;i<5;i++)
{
  for(int j=0;j<8;j++)
  {
   int k=r.nextInt(l.size());
   group[i][j]=l.get(k);
   l.remove(k);
  }
}
for(int i=0;i<5;i++)
{
  System.out.print("Group "+(i+1)+": ");
  for(int j=0;j<8;j++)
  {
      if(group[i][j]<10)
   System.out.print("swe00"+group[i][j]+" ");
   else
    System.out.print("swe0"+group[i][j]+" ");
  }
  System.out.println();
}
System.out.print("请输入学生学号最后两位:");
        double Number=input.nextDouble();
        for(int i=0;i<5;i++)
        {
            for(int j=0;j<8;j++)
            {
                if(Number==group[i][j])
                {
                    System.out.println("该学生在第"+(i+1)+"组,该组成员有:");
                    int b;
                    for(int k=0;k<8;k++)
                    {
                        for(int x=k;x<7;x++)
                        {
                            if(group[i][k]>group[i][x+1])
                            {
                                b=group[i][k];
                                group[i][k]=group[i][x+1];
                                group[i][x+1]=b;
                            }   
                        }
    System.out.print("swe00"+group[i][j]+" ");
                    }
                    System.out.println();
                }
               
            }
        }
    }
}
搜索更多相关主题的帖子: void public Random import 
2012-05-08 22:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-367206-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.119469 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved