问题 F: A+B和C (15)
不出所料,果真用int超限,会报:答案错误50%
于是纠正一下,改成long long ;不过改成long long 也对的!
AC代码:
1 #include <iostream> 2 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 4 using namespace std; 5 int n; 6 long long a,b,c; 7 bool compare(){ 8 if(a+b>c) return true; 9 else return false; 10 } 11 int main(int argc, char** argv) { 12 13 while(cin>>n){ 14 int i=1; 15 while(i<=n){ 16 cin>>a>>b>>c; 17 if(compare()) cout<<"Case #"<<i<<": "<<"true"; 18 else cout<<"Case #"<<i<<": "<<"false"; 19 cout<<endl; 20 i++; 21 } 22 } 23 return 0; 24 }
原文:https://www.cnblogs.com/industrial-fd-2019/p/10629207.html