C/C++ Programming Learning-Week 21 ⑧ Conditional Output 3

Topic link

Title description

Programmatically input four integers a, b, c, d, when a+b is greater than 10, output the value of a b, otherwise when b+c>5, output the value of c d, otherwise when d<10 or a* Output Yes when c>100, otherwise output No

Input
4 integers a, b, c, d, separated by spaces

Output
output the corresponding result

Sample Input

1 6 9 7

Sample Output

63

Ideas

Input four integers a, b, c, d, when a+b is greater than 10, output the value of a b, otherwise output the value of c d when b+c>5 , otherwise when d<10 or a*c> Output Yes when 100, otherwise output No.

C++ code:

#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;
}

Guess you like

Origin blog.csdn.net/qq_44826711/article/details/113572398