ACM第一期练习题第八小题:A + B Problem Too

click here to have a try first
题目要求:
Time limit : 1000 ms
Memory : 32768 KB

题目原题:

This problem is also a A + B problem,but it has a little difference,you should determine does (a+b) could be divided with 86.For example ,if (A+B)=98,you should output no for result.
Input
Each line will contain two integers A and B. Process to end of file.

Output
For each case, if(A+B)%86=0,output yes in one line,else output no in one line.
Sample Input
1 1
8600 8600
Sample Output
no
yes

问题简述:
输入两个数字,两个数字之间以空格分开,计算两个数字相加的和除于86的余数是否为零,若是在下一行输出yes,否在下一行输出yes,且要求可以输入多组数据。

问题分析:

考虑利用while()来创造输入多组数据的条件。
Virtua Judge通过的代码为:

#include <iostream>
using namespace std;
int main()
{
	int A, B;
	while (scanf_s("%d%d", &A, &B)!=EOF)
	{
		if ((A + B) % 86 == 0)
		{
			printf("yes\n");
		}
		else
		{
			printf("no\n");
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43697280/article/details/84874095
今日推荐