日期:2014-05-20  浏览次数:20755 次

java小问题
[align=center][/align][code=Java][/code]
import java.util.*;
public class Test3
{
public static void main(String []args)
{
Scanner reader=new Scanner(System.in);
int score,all,max,min,avg;
System.out.println("有几名选手?");
int g=reader.nextInt();
int player[][]=new int[2][g];
for(int j=0;j<g;j++)
{
player[0][j]=j+1;
}
int m=0;
while(g-m!=2)
{
for(int y=m;y<g;y++)
{
System.out.println("请给"+player[0][y]+"号选手评分!");
int i=1;
System.out.print("请输入一组评委的分数:");
reader.useDelimiter("\\s");
score=reader.nextInt();
all=score;
min=max=score;
while(reader.hasNextInt())
{
score=reader.nextInt();
all+=score;
max=max>score?max:score;
min=min<score?min:score;
i++;
}
avg=(all-max-min)/(i-2);
player[1][y]=avg;
}
int flag0,flag1;
for(int p=m;p<g-m;p++)//排序
{
for(int q=g;q>m;q--)
{
if(player[1][p]>player[1][q])
{
flag0=player[0][p];
flag1=player[1][p];
player[0][p]=player[0][q];
player[1][p]=player[1][q];
player[0][q]=flag0;
player[1][q]=flag1;
}
}
}
System.out.println("淘汰的选手是"+player[0][m]+"号选手,平均分是"+player[1][m]+"分。");
m++;
if(g-m!=2)
{
System.out.println("第"+(m+1)+"轮的出场顺序是:");
for(int x=m;x<g;x++)
{
System.out.println(player[0][x]+"号选手,平均分"+player[1][x]);
}
}
}
System.out.println("冠军是"+player[0][g-1]+"号选手,平均成绩是"+player[1][g-1]+"奖励商品房一套!");
System.out.println("亚军是"+player[0][g-2]+"号选手,平均成绩是"+player[1][g-2]+"奖励小轿车一辆!");
}
}[size=12px][/size]

------解决方案--------------------
输入不匹配