sairate 4108f6c42d docs(book): 添加现代 C++教程及相关代码
- 新增现代 C++ 教程的 Preface 章节,包括英文和中文版本
- 添加 C++ Primer 练习代码
- 新增 Learn C++ 教程的 C++ 开发简介章节
- 添加头文件解析文档
- 更新 mkdocs.yml,包含新教程的目录结构
- 修改项目设置,使用 Python 3.10环境
2025-07-06 16:14:43 +08:00

32 lines
615 B
C++

#include <iostream>
#include <vector>
#include <ctime>
#include <cstdlib>
using namespace std;
int main() {
vector<int> vInt;
const int sz = 10;
srand((unsigned ) time(NULL));
cout <<"数组的初始值为" << endl;
for(int i = 0; i != sz; ++i) {
vInt.push_back(rand() % 100);
cout << vInt[i] << " ";
}
cout <<endl;
for(auto &val : vInt) {
val = (val % 2 == 0) ? val : val * 2;
}
cout <<"最终数组为" << endl;
for(auto it = vInt.cbegin(); it != vInt.cend(); ++it) {
cout << *it << " ";
}
cout <<endl;
return 0;
}