永发信息网

[300分]急求C语言原程序!!

答案:4  悬赏:40  手机版
解决时间 2021-01-06 20:44
  • 提问者网友:焚苦与心
  • 2021-01-05 20:34
[300分]急求C语言原程序!!
最佳答案
  • 五星知识达人网友:摆渡翁
  • 2021-01-05 22:12
#include
#include

struct point
{
float x;
float y;
};

get_point(struct point *p)
{
float a,b;
scanf("%f,%f",&a,&b);
p->x=a;
p->y=b;
return 0;
}

put_point(struct point a)
{
printf("%f,%f\n",a.x,a.y);
return 0;
}

struct point add(struct point a,struct point b)
{
struct point c;
c.x=a.x+b.x;
c.y=a.y+b.y;
return c;
}

struct point sub(struct point a,struct point b)
{
struct point c;
c.x=a.x-b.x;
c.y=a.y-b.y;
return c;
}

float triangle(struct point A, struct point B, struct point C)
{
float a,b,c,p,area;
struct point d,e,f;
d=sub(A,B);
e=sub(A,C);
f=sub(B,C);

c=sqrt(d.x*d.x+d.y*d.y);
b=sqrt(e.x*e.x+e.y*e.y);
a=sqrt(f.x*f.x+f.y*f.y);

p=(a+b+c)/2;
area=sqrt(p*(p-a)*(p-b)*(p-c));
return area;
}

main()
{
struct point a,b,c,n;
printf("Please input a point:");
get_point(&a);
printf("The Point you input is: ");
put_point(a);

printf("Please input 3 points of triangle :");
get_point(&a);
get_point(&b);
get_point(&c);

printf("The area of triangle is:%f\n",triangle(a,b,c));
printf("输入平移向量坐标:");
get_point(&n);
a=add(a,n);
b=add(b,n);
c=add(c,n);
printf("平移后三角形面积为:%f",triangle(a,b,c));
}

我用turbo c2.01运行过,除了中文无法显示外,程序没问题。
你如果用visual c++运行的话中文应该能显示
全部回答
  • 1楼网友:妄饮晩冬酒
  • 2021-01-06 02:38
到专业网站去吧
  • 2楼网友:白昼之月
  • 2021-01-06 01:15
去www.csdn.net上面的C语言区发吧.那里会的并且乐于帮助的人很多.
  • 3楼网友:山君与见山
  • 2021-01-05 23:44
main()
{
struct point a,b,c,n;
printf("Please input a point:");
get_point(&a);
printf("The Point you input is: ");
put_point(a);
printf("The area of triangle is:%f\n",triangle(a,b,c));
printf("输入平移向量坐标:");
get_point(&n);
a=add(a,n);
b=add(b,n);
c=add(c,n);
printf("平移后三角形面积为:%f",triangle(a,b,c));
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯