#include <iostream>
using namespace std;
#define day 7
int main()
{
short num1= 2;
cout << " num1 = " << num1 << endl;
int num2 = 10;
cout << " num2 = " << num2 << endl;
cout << "short占用的内存空间是 " << sizeof(short) << endl;
cout << "short占用的内存空间是 " << sizeof(num1) << endl;
cout << "一周有" << day <<"天"<< endl;
const int month = 12;
cout << "一年有" << month <<"个月"<< endl;
cout << "hello world"<<endl;
float f1 = 3.14f;
double d1 = 3.1415926;
cout << "f1=" << f1 << endl;
cout << "d1=" << d1 << endl;
cout << "float占用的内存空间是 " << sizeof(float)<<"字节" << endl;
cout << "double占用的内存空间是 " << sizeof(double) << "字节" << endl;
float f2 = 3e2;
cout << "f2=" << f2 << endl;
float f3 = 3e-2;
cout << "f3=" << f3 << endl;
char ch = 'a';
char ch1 = 'A';
cout << "ch=" << ch << endl;
cout << "字符型变量所占的内存空间" << sizeof(char) <<"byte"<< endl;
cout <<"a的ASCII编码是"<< (int)ch << endl;
cout << "A的ASCII编码是"<<(int)ch1 << endl;
system("pause");
return 0;
}
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
cout << "hello C++ \n";
cout << "\\ \n";
cout << "aaaa\thello world" << endl;
cout << "aaa\thello world" << endl;
cout << "aaaaa\thello world" << endl;
char str[] = "hello world";
cout << str << endl;
string str2 = "hello world";
cout << str2 << endl;
bool flag = true;
cout << flag << endl;
flag = false;
cout << flag << endl;
cout <<"bool数据类型所占的内存空间"<< sizeof(bool)<<" byte" << endl;
cout << "\n" << endl;
int a = 0;
cout << "请输入整型数据变量" << endl;
cout << "整型数据变量a为:" << a << endl;
cout << "\n" << endl;
int x1 = 10;
int y1 = 3;
int z1;
z1 = x1 / y1;
cout << "z1=" << z1 << endl;
int y2 = 20;
double z2;
z2 = (double)x1 / y2;
cout << "z2=" <<setprecision(2) << z2 <<endl;
int b = 2, c;
c = ++b;
c = b++;
cout << "\n" << endl;
int m = 0;
m += 2;
cout << " m的值为 " <<m<< endl;
cout << "\n" << endl;
m -= 2;
cout << " m的值为 " << m << endl;
cout << "\n" << endl;
system("pause");
return 0;
}