C/C++ Programming Learning-Week 4 ⑧ Xiao Suan Suan's results

Topic link

Title description

Xiao Suan Suan told you about her language and math scores, to determine whether one of the subjects happened to fail (score less than 60 points).

Input format
One line, containing two integers between 0 and 100, which are the student's language score and math score.

Output format
If the student fails one course, output 1; otherwise, output 0.

Sample Input

50 80

Sample Output

1

Ideas

Enter two numbers and determine if one of them is less than 60.

C language code:

#include<stdio.h>
int main()
{
    
    
	int x, y;
	scanf("%d%d", &x, &y);
	if((x < 60 && y >= 60) || (x >= 60 && y < 60)) printf("1");
	else printf("0");
	return 0;
}

C++ code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
	int a, b;
	while(cin >> a >> b)
		if((a < 60 && b >= 60) || (a >= 60 && b < 60)) cout << "1" << endl;
		else cout << "0" << endl;
	return 0;
}

Guess you like

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