我的代码不知道是哪儿出问题了,希望得到各位解答!
查看原帖
我的代码不知道是哪儿出问题了,希望得到各位解答!
370808
themysteryboy楼主2021/1/20 18:36

我的代码逻辑上应该是没问题的,但是运行的时候却只能输入两行,我明明for循环了8次,所以不知道为什么,求解!

代码如下:

#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <set>

using namespace std;

int main() {
    int school = 0, other = 0;
    int day = 0;    
    int sum = 0;
    int max = 0;
    for (int i = 1; i < 8; i++) {
        cin >> school >> other;
        sum = school + other;
        if (sum > max && sum > 8) {
            max = sum;
            day = i;
        }
    cout << day << endl;
    return 0;
    }
}

谢谢各位解答!!!

2021/1/20 18:36
加载中...