C++津津上初中了。妈妈认为津津应该更加用功学习所以津津除了上学之外还要参加妈妈为她报名的各科复习班。另外每周妈妈还会送她去学习朗诵、舞蹈和钢琴。但是津津如果一天上课超过八个小时就会不高兴而且上得越久就会越不高兴。假设津津不会因为其它事不高兴并且她的不高兴不会持续到第二天。请你帮忙检查一下津津下周的日程安排看看下周她会不会不高兴;如果会的话哪天最不高兴。【输入】包括七行数据分别表示周一到周日的日程
#include
int main() { int schedule[7][2]; int max_unhappy = 0; int unhappy_day = 0;
for(int i=0; i<7; i++){
cin >> schedule[i][0] >> schedule[i][1];
}
for(int i=0; i<7; i++){
int total_hours = schedule[i][0] + schedule[i][1];
if(total_hours > 8 && total_hours - 8 > max_unhappy){
max_unhappy = total_hours - 8;
unhappy_day = i+1;
}
}
cout << unhappy_day << endl;
return 0;
原文地址: https://www.cveoy.top/t/topic/hQfz 著作权归作者所有。请勿转载和采集!