C++自学计划-循环-09

1.while

例子:

    int a = 10;
    int b = 20;
    while (b > a) {
        a += 1;
        std::cout << a << std::endl;
    }

2.do...while

int a = 10;
    int b = 20;

    do {
        a += 1;
        std::cout << a << std::endl;
    } while (b > a);

3.for

for (int i = 0; i < 10; ++i) {
        std::cout << i << std::endl;
}

你可能感兴趣的:(C++自学计划-循环-09)