C/C++编程学习 - 第21周 ⑧ 条件输出3

题目链接

题目描述

编程实现输入四个整数a,b,c,d,当a+b大于10时,输出ab的值,否则当b+c>5时输出cd的值,否则当d<10或者a*c>100时输出Yes,否则输出No

Input
输入4个整数a,b,c,d,以空格隔开

Output
输出相应结果

Sample Input

1 6 9 7

Sample Output

63

思路

输入四个整数a,b,c,d,当a+b大于10时,输出ab的值,否则当b+c>5时输出cd的值,否则当d<10或者a*c>100时输出Yes,否则输出No。

C++代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
	long long a, b, c, d;
	while(cin >> a >> b >> c >> d)
	{
    
    
		if(a + b > 10) cout << a * b << endl;
		else if(b + c > 5) cout << c * d << endl;
		else if(d < 10 || a * c > 100) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44826711/article/details/113572398