网络赛前10奖励计蒜客的本子或鼠标垫(外校也可以来现场领取)
Xidian Online Judge WebBoard
[ New Thread ]
Problem 1021 >> 错哪了
07114099 @ 2015-05-04 20:08:06
[ Quote ] [ Edit ] [ Delete ] 1#
#include <stdio.h>
#include <math.h>
int main()
{
unsigned char t,n,m;
double a,pi=3.1415926535897932;
scanf("%d",&t);
for(m=1;m<=t;m++)
{
scanf("%d %lf",&n,&a);
printf("%.4lf\n",n*pow(a,2)*tan(pi*(1-2./n)/2.)/4.);
}
return 0;
}
110 @ 2015-05-04 21:14:14
[ Quote ] [ Edit ] [ Delete ] 2#
换一个更加精确的PI acos(-1)
07114099 @ 2015-05-04 21:17:29
[ Quote ] [ Edit ] [ Delete ] 3#
我试过了,换了也不行
110 @ 2015-05-04 21:21:32
[ Quote ] [ Edit ] [ Delete ] 4#
哦 那就是你写错了
14030130073 @ 2015-05-04 21:36:21
[ Quote ] [ Edit ] [ Delete ] 5#
它也一直说我错,可能是格式什么的问题
07114099 @ 2015-05-04 21:41:38
[ Quote ] [ Edit ] [ Delete ] 6#
我估计也是格式
xry111 @ 2015-05-04 21:56:32
[ Quote ] [ Edit ] [ Delete ] 7#
G++ gives follow WARNINGs with -Wall -Wextra -O2:
test.cpp:7:14: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘unsigned char*’ [-Wformat=]
scanf("%d",&t);
^
test.cpp:10:21: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘unsigned char*’ [-Wformat=]
scanf("%d %lf",&n,&a);
^
So the behaviour of your program is definitely undefined. You should stop cheat yourself with "this is a simple format error".
xry111 @ 2015-05-04 21:59:56
[ Quote ] [ Edit ] [ Delete ] 8#
Sorry. "cheat" should be "cheating".
windroid @ 2015-05-04 23:23:11
[ Quote ] [ Edit ] [ Delete ] 9#
西电ACM英语讲堂开课啦OLZ
[Top] [Previous Page] [Next Page]
Anything about the Problems, Please Contact Admin:admin
All Copyright Reserved 2010-2014 Xidian ACM Online Judge TEAM
GPL2.0 2003-2014 HUSTOJ Project TEAM