简单OJ题目,为何WA?分不多,仍请各位赐教!

题目:TheCenterofGravityTimeLimit:3000/1000MS(Java/Others)MemoryLimit:32768/32768K(Java/... 题目:
The Center of Gravity
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1209 Accepted Submission(s): 615

Problem Description
Everyone know the story that how Newton discovered the Universal Gravitation. One day, Newton walked
leisurely, suddenly, an apple hit his head. Then Newton discovered the Universal Gravitation.From then
on,people have sovled many problems by the the theory of the Universal Gravitation. What's more, wo also
have known every object has its Center of Gravity.
Now,you have been given the coordinates of three points of a triangle. Can you calculate the center
of gravity of the triangle?

Input
The first line is an integer n,which is the number of test cases.
Then n lines follow. Each line has 6 numbers x1,y1,x2,y2,x3,y3,which are the coordinates of three points.
The input is terminated by n = 0.

Output
For each case, print the coordinate, accurate up to 1 decimal places.

Sample Input
2
1.0 2.0 3.0 4.0 5.0 2.0
1.0 1.0 4.0 1.0 1.0 5.0
0

Sample Output
3.0 2.7
2.0 2.3

我的程序:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
int m=1,n,i;
float a,b,x[3],y[3];
scanf("%d",&n);
if(n==0) goto loop;
while(m<=n)
{
a=b=0;
for(i=0;i<=2;i++)
{
scanf("%f %f",&x[i],&y[i]);
a=a+x[i];
b=b+y[i];
}
printf("%.1f %.1f\n",a/3,b/3);
m++;
}
loop:;
//system("PAUSE");
return 0;
}
链接:http://acm.hdu.edu.cn/listproblem.php?vol=12
2105 The Center of Gravity
(杭电测试平台)
展开
 我来答
百度网友713311912
2009-07-12 · TA获得超过182个赞
知道答主
回答量:135
采纳率:100%
帮助的人:149万
展开全部
给个原题链接吧,否则我也没法测试。

我的一个猜想是:
既然题目说n=0表示输入终止,那么是否意味着如下输入是合法的:

2
1.0 2.0 3.0 4.0 5.0 2.0
1.0 1.0 4.0 1.0 1.0 5.0
3
1.0 2.0 3.0 4.0 5.0 2.0
1.0 1.0 4.0 1.0 1.0 5.0
1.0 1.0 1.0 1.0 1.0 1.0
0

前三行n=2,然后两行是坐标;
4至7行输入中,n=3,接下来三行坐标;
第八行n=0,输入终止。

PS:
感觉你的if(n==0) goto loop;多余了
还有,baidu上做ACM的貌似不多,这个一般还是去专业的论坛问吧
富港检测技术(东莞)有限公司_
2024-05-27 广告
ISTA3E程序是对相同产品的集合包装的综合模拟性能测试,集合包装件被定义为将一个产品、多个产品或包装件放置在滑板或托盘上,固定在一起或是作为一个单元运输。例如:一台机器由带瓦楞底托的托盘上、瓦楞侧围、顶盖包装,用缠绕膜缠绕在托盘上。用于评... 点击进入详情页
本回答由富港检测技术(东莞)有限公司_提供
zh...i@126.com
2009-07-13
知道答主
回答量:19
采纳率:0%
帮助的人:0
展开全部
三角形重心计算公式会不会的额。。。
#include<iostream>
using namespace std;
int main()
{
double x1,y1,x2,y2,x3,y3;
int n;
while(scanf("%d",&n)!=EOF&&n)
{
for(int i=0;i<n;i++)
{
scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
double ans_x=(x1+x2)/2,ans_y=(y1+y2)/2;
ans_x+=(x3-ans_x)/3,ans_y+=(y3-ans_y)/3;
printf("%.1lf %.1lf\n",ans_x,ans_y);
}
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式