| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请问我的算法是否有问题……?能否告诉我从哪组数据开始出错?万分感谢!!#include<stdio.h>
main()
{ double s1[200],s2[200];
int i,round;
double a_win,b_win,tie;
float a,b,t;
for(i=0;i<200;i++)
s1[i]=s2[i]=0;
printf("Round A wins B wins Tie\n");
s1[103]=1*100/(double)(16);
s1[102]=2*100/(double)(16);
s1[101]=4*100/(double)(16);
s1[100]=6*100/(double)(16);
s1[99]=2*100/(double)(16);
s1[97]=1*100/(double)(16);
a_win=7*100/(double)(16);
b_win=3*100/(double)(16);
tie=6*100/(double)(16);
a=(float)(a_win);
b=(float)(b_win);
t=(float)(tie);
printf(" 1 %7.4f%% %7.4f%% %7.4f%%\n",a,b,t);
for(round=2;round<=20;round++)
{ for(i=100-3*round;i<=100+3*round;i++)
{s1[i]=s1[i]/16;
s2[i]=0;
}
for(i=100-3*(round-1);i<=100+3*(round-1);i++)
{ s2[i+3]=s2[i+3]+s1[i];
s2[i+2]=s2[i+2]+2*s1[i];
s2[i+1]=s2[i+1]+4*s1[i];
s2[i]=s2[i]+6*s1[i];
s2[i-1]=s2[i-1]+2*s1[i];
s2[i-3]=s2[i-3]+s1[i];
}
for(i=100-3*round,b_win=0;i<100;i++)
b_win=b_win+s2[i];
for(i=101,a_win=0;i<=100+3*round;i++)
a_win=a_win+s2[i];
tie=s2[100];
a=(float)(a_win);
b=(float)(b_win);
t=(float)(tie);
printf("%5d %7.4f%% %7.4f%% %7.4f%%\n",round,a,b,t);
for(i=100-3*round;i<=100+3*round;i++)
s1[i]=s2[i];
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator