为什么我是错的!!😿😿

3076768864 2024-04-20 17:31:58 11

#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a; c = 1; for (int i = 1; i <= a; ++i) { b += c; c += 1; } cout << b; return 0; }

{{ vote && vote.total.up }}

共 5 条回复

3076768864

谢谢!!!😀😀

root 站长

累加求和的变量要赋值0

root 站长
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a;
    for (int i = 1; i <= a; ++i) {
        b += i;
    }
    cout << b;
    return 0;
}

你这个代码就很不错,

3076768864

请大神们指点一下!!!👀👀

3076768864

!!!