有个坑,如果两个向量分别是(-0.02,-0.02)和(0,0),
如果没有判断那一步的话,答案会出现 -0.0的情况
#include<stdio.h>
struct xiang{
double x;
double y;
};
int main (void)
{
struct xiang a,b,t;
scanf("%lf %lf %lf %lf", &a.x, &a.y, &b.x, &b.y);
double x,y;
t.x = a.x + b.x;
t.y = a.y + b.y;
if (t.x > -0.05 && t.x < 0) // 判断
t.x = 0;
if (t.y> -0.05 && t.y < 0)
t.y = 0;
printf("(%.1f, %.1f)\n", t.x, t.y);
return 0;
}