#include <iostream>
using namespace std;
int main() {
int count = 0;
// while 循环示例
while (count < 5) {
cout << "当前计数: " << count << endl;
count++; // 计数器加1
}
return 0;
}
#include <iostream>:包含输入输出流库,用于处理输入输出操作。using namespace std;:使用标准命名空间,避免每次调用标准库函数时都要加上 std:: 前缀。int main():主函数,程序从这里开始执行。int count = 0;:定义一个整型变量 count,并初始化为 0。while (count < 5):当 count 小于 5 时,循环体内的代码会不断执行。cout << "当前计数: " << count << endl;:输出当前的计数值,并换行。count++;:每次循环后,count 的值加 1,直到 count 不再小于 5,循环结束。上一篇:c++ readqueue
下一篇:c++ helloworld
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站