这个题目最后的输出带小数,所以需要考虑四舍五入(其实并没有什么道理,但是四舍五入才能ac)
提到的知识点:
1e-6/1e-3等等表明科学计数法,1的负几次方,由于误差常常累计
习惯上吧1e-6到1e-9次记作0
这个考虑四舍五入,所以吧0.05作为分界线
#include<stdio.h>
#include<math.h>
typedef struct Plane {
double x, y;
}Plane;
int main()
{
Plane vector1;
Plane vector2;
scanf("%lf %lf %lf %lf", &vector1.x, &vector1.y, &vector2.x, &vector2.y);
double x = vector1.x + vector2.x;
double y = vector1.y + vector2.y;
if (fabs(x) < 0.05)x = 0.0;
if (fabs(y) < 0.05)y = 0.0;
printf("(%.1lf, %.1lf)",x,y);
}
浙公网安备 33010602011771号