数据类型和运算符
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "hello world" << endl;
short num1 = 10;
cout << "short占用的内存空间为:" << sizeof(short) << endl;
int num2 = 10;
cout << "int占用的内存空间为:" << sizeof(num2) << endl;
long num3 = 10;
cout << "long占用的内存空间为:" << sizeof(num3) << endl;
long long num4 = 10;
cout << "long long占用的内存空间为:" << sizeof(num4) << endl;
float f1 = 3.1415926f;
cout << "f1=" << f1 << endl;
cout << "float占用的内存空间为:" << sizeof(f1) << endl;
double d1 = 3.1415926f;
cout << "d1=" << d1 << endl;
cout << "double占用的内存空间为:" << sizeof(d1) << endl;
float f2 = 3e2;
cout << "f2=" << f2 << endl;
float f3 = 3e-3;
cout << "f3=" << f3 << endl;
char ch = 'a';
cout << ch << endl;
cout << "char字符型变量占用的内存空间为:" << sizeof(ch) << endl;
cout << ch << "字符对应的ASCII编码为:" << (int)ch << endl;
cout << "hello world\n";
cout << "\\" << endl;
cout << "aaa\t hello world" << endl;
cout << "aa\t hello world" << endl;
cout << "aaaaaa\t hello world" << endl;
char str[] = "hello_world";
cout << str << endl;
string str2 = "hello_world";
cout << str2 << endl;
bool flag = true;
cout << "bool字符型变量占用的内存空间为:" << sizeof(flag) << endl;
int a1 = 10;
int b1 = 3;
cout << a1 + b1 << endl;
cout << a1 - b1 << endl;
cout << a1 * b1 << endl;
cout << a1 / b1 << endl;
int a2 = 10;
int b2 = 20;
cout << a2 / b2 << endl;
int a3 = 10;
int b3 = 0;
double d2 = 0.5;
double d3 = 0.22;
cout << d2 / d3 << endl;
int a4 = 10;
int b4 = 3;
cout << a4% b4 << endl;
int a5 = 10;
int b5 = 20;
cout << a5% b5 << endl;
int a6 = 10;
int b6 = 0;
int a = 10;
a++;
cout << "a=" << a << endl;
int b = 10;
b++;
cout << "b=" << b << endl;
int a7 = 10;
int b7 = ++a7 * 10;
cout << "a7=" << a7 << endl;
cout << "b7=" << b7 << endl;
int a8 = 10;
int b8 = a8++ * 10;
cout << "a8=" << a8 << endl;
cout << "b8=" << b8 << endl;
int a9 = 10;
a9 = 10;
cout << "a9=" << a9 << endl;
a9 += 2;
cout << "a9=" << a9 << endl;
a9 -= 2;
cout << "a9=" << a9 << endl;
a9 *= 2;
cout << "a9=" << a9 << endl;
a9 /= 2;
cout << "a9=" << a9 << endl;
a9 %= 2;
cout << "a9=" << a9 << endl;
int a10 = 10;
int b10 = 20;
cout << (a10 == b10) << endl;
cout << (a10 != b10) << endl;
cout << (a10 < b10) << endl;
cout << (a10 > b10) << endl;
cout << (a10 <= b10) << endl;
cout << (a10 >= b10) << endl;
int a11 = 10;
cout << "!a11逻辑非" << !a11 << endl;
cout << !!a11 << endl;
int a12 = 0;
int b12 = 10;
cout << (a12 && b12) << endl;
cout << (a12 || b12) << endl;
int aa = 0;
cout << "!aa逻辑非" << !aa << endl;
bool bb = true;
cout << "布尔类型" << bb << endl;
system("pause");
return 0;
}