1065.A+B and C (64bit)

【題意】
        判斷三個整數A、B、C是否滿足A+B>C

【思路】
        直接碼

【注意點】

        注意對溢出的處理即可


#include <iostream>
using namespace std;

int main(int argc, char const *argv[])
{
	long long a,b,c;
	int t;

	cin >> t;
	for(int i=1; i<=t; i++){
		cin >> a >> b >> c;
		cout << "Case #" << i << ": ";
		if((a>=0 && b<=0) || (a<=0 && b>=0)){
			if(a+b>c){
				cout << "true" << endl;
			}
			else{
				cout << "false" << endl;
			}
		}
		else if(a>0){
			if(a+b<a){
				cout << "true" << endl;
			}
			else if(a+b>c){
				cout << "true" << endl;
			}
			else{
				cout << "false" << endl;
			}
		}
		else if(a<0){
			if(a+b>a){
				cout << "false" << endl;
			}
			else if(a+b>c){
				cout << "true" << endl;
			}
			else{
				cout << "false" << endl;
			}
		}
	}
	system("pause");
	return 0;
}


發佈了99 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章