cppCPU占用时长 100秒内存使用限制 128MB题目描述CZ中学每学期都会给学生提供丰厚的奖学金但是要想获得这些奖学金也不是一件容易的事情。CZ中学对学生成绩的评定一共有A、B、C、D共4个等级提供的奖学金有如下几种:A 竞赛奖学金 提供给至少在一门学科竞赛中获得省级一等奖以上奖项并且语数英三门课的成绩被评定为A或B而且还是三好学生的同学奖金3000元 B 华英奖学金 提供给至少在一门学科竞
#include <iostream>
#include <string>
using namespace std;
int main() {
string grades;
int competition[5];
char goodStudent, poorStudent;
int scholarship = 0;
// input grades
cin >> grades;
// input competition scores
for (int i = 0; i < 5; i++) {
cin >> competition[i];
}
// input if good student
cin >> goodStudent;
// input if poor student
cin >> poorStudent;
// check for competition scholarship
bool competitionScholarship = false;
for (int i = 0; i < 5; i++) {
if (competition[i] == 1) {
competitionScholarship = true;
break;
}
}
// check for good student scholarship
bool goodStudentScholarship = (grades == "AAAAA");
// check for poor student scholarship
bool poorStudentScholarship = (poorStudent == 'Y');
// calculate scholarship amount
if (competitionScholarship && goodStudentScholarship && !poorStudentScholarship) {
scholarship = 3000;
} else if (competitionScholarship && !poorStudentScholarship) {
scholarship = 2000;
} else if (goodStudentScholarship && !poorStudentScholarship) {
scholarship = 1000;
}
// output scholarship amount
cout << scholarship << endl;
return 0;
}
``
原文地址: https://www.cveoy.top/t/topic/iEsI 著作权归作者所有。请勿转载和采集!