在 线 求 助 2
查看原帖
在 线 求 助 2
763339
lanchenhao2010楼主2022/8/9 15:27
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int main(){
    int cost,s = 0,y = 0;
    for(int i = 1;i <= 12;i++){
        cin >> cost;
        s += 300;
        s -= cost;
        if(s < 0){
            printf("-%d",i);
            return 0;
        }
        y += s / 100;
        s = s % 100;
        }
    }
    s += y * 120;
    cout << s;
    return 0;
}

提交评测,斩获一个编译错误:

/tmp/compiler_mv5x9p4j/src:19:5: 错误:‘s’不是一个类型名
   19 |     s += y * 120;
      |     ^
/tmp/compiler_mv5x9p4j/src:20:5: 错误:‘cout’不是一个类型名
   20 |     cout << s;
      |     ^~~~
/tmp/compiler_mv5x9p4j/src:21:5: 错误:expected unqualified-id before ‘return21 |     return 0;
      |     ^~~~~~
/tmp/compiler_mv5x9p4j/src:22:1: 错误:expected declaration before ‘}’ token
   22 | }
      | ^

有大佬能告诉我哪错了吗【跪】?

2022/8/9 15:27
加载中...