设n组老尘迟坐标,则质心(x', y'),,侍李其中 x'=1/n * (x1+...+xn)y'=1/n * (y1+...+yn)。
代码:
#include<stdio.h>
struct point{
float x
float y
}
int main()
{
struct point pos[100]
int n,i
float sumX = 0,sumY = 0
printf("input number(0<n<=100):")
scanf("%d",&n)
printf("input pos (x,y):\n")
for(i=0i<ni++)
{
scanf("%f,%f"兄基,&pos[i].x,&pos[i].y)
sumX += pos[i].x
sumY += pos[i].y
}
printf("pos :(%lf,%lf)\n",sumX/n,sumY/n)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)