C++中可以修饰的变量
相比C语言 增加了 bool 型变量
命名空间
using namespace
库的区别
例如 <stdio.h>和<iostream>
<math.h> 和<cmath>
C 语言完整继承了 C 语言的绝大多数库。C 语言中引用 math 库时的文件名是math.h,虽然在 C 语言中,依然可以这么写,但是在 C 中都应该这么写,即以c某某某的名字引入
#include <iomanip>
输入输出流格式
fixed和setprecision来设置cout的输出精度
cout << fixed << setprecision(4) << value << endl;
// 加了fixed意味着是固定点方式显示,所以这里的精度指的是小数位
cin格式化输入
cin.get(ch)
样例输入
2016-2-29
我们只获取数字,则代码如下:
int main()
{
int a,b,c,d;
char ch;
cin >> a ;
cin.get(ch);
cin >> b;
cin.get(ch);
cin >> c;
cout << a <<endl << b << endl << c <<endl;
}
continue & go to
流程控制语句:continue与goto。goto的作用则是跳转到指定的某个语句