首页 > 代码库 > PAT 1065. A+B and C (64bit)

PAT 1065. A+B and C (64bit)

 1 #include <stdio.h> 2  3 int main() { 4         long n, a, b, c; 5         long i; 6         int ga, gb, gc, r; 7         scanf("%ld", &n); 8         for (i=0; i<n; i++) { 9                 scanf("%ld%ld%ld", &a, &b, &c);10                 ga = a >= 0;11                 gb = b >= 0;12                 gc = c >= 0;13                 if (ga && gb) {14                         if (gc) {15                                 r = a > c - b;16                         } else {17                                 r = 0;18                         }19                 } else if (!ga && !gb) {20                         if (gc) {21                                 r = 0;22                         } else {23                                 r = a > c - b;24                         }25                 } else {26                         r = a + b > c;27                 }28                 printf("Case #%ld: %s\n", i+1, r ? "true" : "false");29 30         }31         return 0;32 }

纯C,bool都用不了,不习惯了。符号相反的数相加肯定不会溢出。水一发。