C语言之Calculus Midterm

欢迎进入我的C语言世界

题目

Problem Description

Yellowstar刚考完微积分期中考,微积分期中考卷一共三个部分,8道选择题每题3分,8道填空题,每题2分,10题答题每题6分,总分100分。Yellowstar考完期中考后已经失去了计算能力,他只记得每部分对的题数,现在想请你帮忙计算一下他的得分,能否通过考试。

Input

多组数据,处理到EOF。

每组数据输入3个整数 x,y,z(0<=x<=8,0<=y<=8,0<=z<=10)分别表示选择题、填空题和简答题正确的题数。

Output

每组数据需要输出两行,如果他最少的得分大于等于60 ,第一行输出“I passed the exam.”(双引号不需要输出),第二行输出他的得分;如果他最低得分小于60,第一行输出“Exam was too hard.”(双引号不需要输出),第二行输出他的得分。

Sample Input

8 8 10
0 0 0

Sample Output

I passed the exam.
100
Exam was too hard.
0

答案

下面展示 实现代码

#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
    
    
	int x, y, z;
	while(scanf("%d%d%d",&x,&y,&z) != EOF)
	{
    
    		
		int sum = 3 * x + 2 * y + 6 * z;
		if(sum >= 60)
		{
    
    
			cout << "I passed the exam." << "\n" << sum << endl;
		}
		else if (sum <60)
		{
    
    
			cout << "Exam was too hard." << "\n" << sum << endl;
		}
	} 
	return 0;
} 

本题感悟

本块内容可能来自课本或其他网站,若涉及侵权问题,请联系我进行删除,谢谢大家啦~

这题还挺水的hhh
以上。

猜你喜欢

转载自blog.csdn.net/hongguoya/article/details/105654191