欢迎加入西电微软俱乐部招新群 588166170,做出福利题,免技术部第一次面试且赠送“福利”海报或小礼品~~~~
Xidian Online Judge WebBoard
[ New Thread ]
Problem 1021 >> 答案错误,求解
14030110093 @ 2015-05-02 19:37:42
[ Quote ] [ Edit ] [ Delete ] 1#
#include <stdio.h>
#include <math.h>
#define pi 3.1415926535897932
int main ()
{
int a,b=0;
scanf("%d",&a);
while(b < a)
{
double l,s;
int n;
scanf("%d%lf",&n,&l);
//s=sin(2*pi/n)*(l/(2*sin(pi/n)))*(l/(2*sin(pi/n)))*n/2;
s=n*l*l/tan(pi/n)/4;
printf("%.4lf",s);
++b;
}
return 0;
}
xry111 @ 2015-05-02 22:21:30
[ Quote ] [ Edit ] [ Delete ] 2#
You forgot to print '\n'.
For example, if input data is
2
10 10
8 8
This will produce
769.4209309.0193
It's certainly wrong.
wanxiaowei @ 2015-05-03 00:07:22
[ Quote ] [ Edit ] [ Delete ] 3#
And remember to replace %.4lf by %.4f next time when print a double.Maybe sometimes it doesn't matter but it will make you doubt your life when you get a WA because of it.
14030110093 @ 2015-05-03 15:10:26
[ Quote ] [ Edit ] [ Delete ] 4#
thanks

[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