我电脑上没有装VC,这是C#版的,自己去改一下
public static void Main()
{
int[] sh = { 1, 2, 3 };//3个选手,编号为1,2,3
double[] sf = new double[sh.Length];//选手的得分
int[] ph = { 1, 2, 3, 4, 5 };//5个评委,编号为1,2,3,4,5
double[] pf = new double[ph.Length];//pf[j]为第j个评委的得分
int[,] f = new int[sh.Length, ph.Length];//第j个评委给第i个选手的评分
for (int i = 0; i < sh.Length; i++)
{
int max = 0;
int min = 100;
int score = 0;
int count = 0;//用来保存第i个选手的总分
for (int j = 0; j < ph.Length; j++)
{
Console.WriteLine("请评委{0}为选手{1}评分:", ph[j], sh[i]);
score = int.Parse(Console.ReadLine());
f[i, j] = score;
count += score;
if (max < score) max = score;//设置最高分
if (min > score) min = score;//设置最低分
}
sf[i] = ((double)(count - max - min)) / (ph.Length - 2);
Console.WriteLine("{0}的总得分为{1},去掉最高分{2}最低分{3},最后分数为:{4}",sh[i],count,max,min,sf[i]);
}
SetPf(pf, f, sf);//求各个评委的得分
for (int j = 0; j < pf.Length; j++)
Console.WriteLine("评委{0}的得分为{1}",ph[j],pf[j]);
Console.ReadLine();
}
static void SetPf(double[] pf, int[,] f, double[] sf)
{
double count = 0;
for (int i = 0; i < pf.Length; i++)
{
for (int j = 0; j < sf.Length; j++)
count += (f[j, i] - sf[j]) * (f[j, i] - sf[j]);
count = Math.Sqrt(count / sf.Length);
pf[i] = 10 - count;
}
}
[[it] 本帖最后由 slokra 于 2008-6-20 14:53 编辑 [/it]]