您的位置:首页 > 编程语言 > C语言/C++

C++ Primer 读书笔记 - 第一章

2013-05-19 08:02 134 查看
这一章算是简介。

自己写了几个程序。

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: