Skip to content
目录

C++

基础

for 循环

cpp
#include <iostream>;

int forLoop(int n);

int main() {
    std::cout << forLoop(100) << std::endl;
    return 0;
}

int forLoop(int n) {
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        res += i;
    }

    return res;
}