c语言:输入10个点的坐标(设坐标为整数值),输出距原点最远的点(设唯一)的坐标及该点距原点的距离
2个回答
展开全部
#include <stdio.h>
#include <math.h>
int main()
{
int x,y,l, max=-1, maxx, maxy;
int i;
for(i = 0; i < 10; i ++)
{
scanf("%d%d",&x,&y);
l = x*x+y*y;
if(max < l)
{
max = l;
maxx=x;
maxy=y;
}
}
printf("%d %d %lf\n", maxx, maxy, sqrt(max));
return 0;
}
展开全部
#include#includeintmain(){intx1,y1,x2,y2,absx,absy;doubleres;printf("Pleaseinputthefirstpoint(x,y):\n");scanf("%d%d",&x1,&y1);printf("Pleaseinputthesecondpoint(x,y):\n");scanf("%d%d",&x2,&y2);printf("\nfirstpoint:(%d,%d),secondpoint:(%d,%d)\n",x1,y1,x2,y2);absx=abs(x2-x1);absy=abs(y2-y1);//printf("%d%d",absx,absy);res=sqrt((absx*absx)+(absy)*(absy));printf("\nthelenoflineis=%lf\n",res);getch();return0;}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询