c++黑马-P10数据类型实型

#include <iostream>
using namespace std;
int main()
{
float a1 = 3.141552334323423f;
cout <<"a1="<< a1 << endl;
//c++默认只能输出6位的数字
double a2 = 3.1434445442424356256;
cout <<"a2="<< a2 << endl;
cout << "float型占" << sizeof(a1) << "字节" << endl;
cout << "double型占" << sizeof(a2) << "字节" << endl;
//科学计数法
float f2 = 3e2; // 3 * 10 ^ 2
cout << "f2 = " << f2 << endl;
float f3 = 3e-2; // 3 * 0.1 ^ 2
cout << "f3 = " << f3 << endl;
system("pause");
return 0;
}

浙公网安备 33010602011771号