C++ Primer 读书笔记 - 第一章
这一章算是简介。
自己写了几个程序。
1. main函数的返回值
int main() { //after ./a.out, execute 'echo $?', it will output 7. return 7; }
2. 对comment的理解
#include <iostream> using namespace std; int main() { cout << "/*"; cout << "*/"; cout << /* "*/" */"; }
3. 对输入的理解
#include <iostream> using namespace std; int main() { int a; int b; cin >> a >> b; cout << a << "\t" << b << endl; return 0; }
4. 无限输入
#include <iostream> using namespace std; int main() { int sum = 0; int value; // Ctrl + D to end the input while (cin >> value) sum += value; cout << "Sum is: " << sum << endl; return 0; }
---
可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明
可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明