https://pintia.cn/problem-sets/12/problems/345
解决舍入问题。
1 #include <stdio.h> 2 #include <math.h> 3 4 int main(void) 5 { 6 struct p 7 { 8 double x; 9 double y; 10 }; 11 double x, y; 12 13 struct p p1, p2; 14 scanf("%lf %lf %lf %lf", &p1.x, &p1.y, &p2.x, &p2.y); 15 16 x = p1.x + p2.x; 17 y = p1.y + p2.y; 18 19 if (fabs(x) < 0.05) 20 { 21 x = 0; 22 } 23 if (fabs(y) < 0.05) 24 { 25 y = 0; 26 } 27 28 printf("(%.1f, %.1f)", x, y); 29 return 0; 30 }