#include#include using namespace std; int main_day2() { short num1 = 10; //-32768 ~ 32767 int num2 = 100; // long num3 = 1000; // long long num4 = 10000; // cout << num1 << endl; cout << num2 << endl; cout << num3 << endl; cout << num4 << endl; cout << "int占用的内存空间为: " << sizeof(int) << "字节" << endl; cout << "num3占用的内存空间为: " << sizeof(num3) << "字节" << endl; cout << "num4占用的内存空间为: " << sizeof(num4) << "字节" << endl; cout << "n" << endl;//换行 float numble1 = 3.14f; double numble2 = 3.14159265358979; cout << numble1 << endl; cout << numble2 << endl; cout << "float占用的内存空间为: " << sizeof(float) << "字节" << endl; //4字节 cout << "double占用的内存空间为: " << sizeof(double) << "字节" << endl; //8字节 cout << "n" << endl;//换行 char ch = 'a'; cout << ch << endl; cout << "char占用的内存空间为: " << sizeof(char) << "字节" << endl; //4字节 cout << "n" << endl;//换行 cout << "atHelloWorldn" ; cout << "aatHelloWorldn" ; cout << "aaatHelloWorldn"; cout << "aaaatHelloWorldn"; cout << "n" << endl;//换行 char HelloWorld1[] = "HelloWorld"; string HelloWorld2 = "HelloWorld"; cout << HelloWorld1 << endl; cout << HelloWorld2 << endl; cout << "n" << endl;//换行 bool flag = true; cout << flag << endl; flag = false; cout << flag << endl; cout << "bool占用的内存空间为: " << sizeof(bool) << "字节" << endl; //1字节 cout << "n" << endl;//换行 int a = 0; cout << "请输入整型变量a的值:"; cin >> a; cout << "a = " << a << endl; float b = 0.0f; cout << "请输入浮点型变量b的值:"; cin >> b; cout << "b = " << b << endl; char c = 0; cout << "请输入字符型变量c的值:"; cin >> c; cout << "c = " << c << endl; string s = ""; cout << "请输入字符串型变量s的值:"; cin >> s; cout << "s = " << s << endl; bool d = false; cout << "请输入布尔型变量d的值:"; cin >> d; cout << "d = " << d << endl; cout << "n" << endl;//换行 system("pause"); return 0; }



