都在代码里面,说明注释很详细。
快捷键:CTRL+K+C,CTRL+K+U,快速注释和取消注释
//author is haibao007
#include <iostream>
#include<string>
using namespace std;
#define day 7 //宏定义常量
const #const修饰的变量,包括其修饰的变量也是常量
int main() {
//一、整型*********************************************
//cout << "每周有 " << day << " 天" << endl;
//const int month = 12;
//cout << "a year have " << month << " months" << endl;
// //1.短整型(-32768~32767)(-2^15~2^15-1) 2byte
//short num_001 = 32768;
//cout << "num_001 = " << num_001 << endl;
2.整型(-2^31~2^31-1)4byte
//int num_002 = 32768;
//cout << "num_002 = " << num_002 << endl;
3.长整型 (-2^31~2^31-1) 4byte
//long num_003 = 32768;
//cout << "num_003 = " << num_003 << endl;
4.长长整型 (-2^63~2^63-1) 8byte
//long long num_004 = 32768;
//cout << "num_004 = " << num_004 << endl;
/
//sizeof(数据类型/变量)//统计数据类型所占的内存大小
//cout << "num_004 所占内存空间大小为 " << sizeof(num_004) << endl;
//二、浮点型,(实型)表示小数,单精度 float 4byte 7位有效数字 双精度 double 8byte 15~16有效数字
//float f001_01 = 3.1415926f;
//float f001_02 = 3e-5; //正数省略科学计数法
//double d001_01 = 3.1415926536;
//cout << f001_01 << endl;
//cout << f001_02 << endl;
//cout << d001_01 << endl;
//cout << sizeof(f001_01) <<" bytes"<< endl;
//cout << sizeof(d001_01)<<" bytes" << endl;
//三、 字符型,变量,显示单个字符 语法:char ch='a'; char chy="shdj"; bug
//char cha_001 = 'a';
char chy_001 = "shdj"; //单双引号注意只能说单字符
//cout << "char_001===" << cha_001 << endl;
cout << "chsy_001" << chy_001 << endl; //ASCII的32-126可显示打印查看
//cout << "所占空间大小" << sizeof(cha_001) << endl;
//cout << "char_001=ascii=" << int(cha_001) << endl;
//四、字符串型
//1. C char name01[] = "hello";
//2. C++ string name012 = "hello"; //notes:string头文件
//char str001_001[] = "hello world soso";
//string str001_0012 = "wonderful";
//cout << str001_001 << endl;
//cout << str001_0012 << endl;
//五、转义字符——ASCII特殊字符 013 \r 回车 010\n换行开头 092\\单反 009\t水平制表默认8个位置对齐 011\v垂直制表
//六、布尔类型 booL ,TRUE or FALSE, 0 1 格式:bool name002= false;
//cout << "hello world \n";//==cout<<"hello world"<<endl;
//cout << "aaa\t hello\n";
//cout << "b\t hello\n";
//cout << "bcd.f\thello\n"; //点不算,hh 对齐显示666
int aa = 0; //有的小数不能用
int bb = 1; //不定义不能用
cout << "变量1赋值" << endl;
cin >> aa;
cout << "变量1为" << aa << endl;
cout << "变量2的赋值";
cin >> bb;
cout << "两者的累加和 "<<aa + bb << endl;
cout << "两者的乘积为 " << aa * bb << endl;
cout << "相除取整 " << aa / bb << endl;
cout << "取模求余 " << aa % bb << endl;
system("pause");
return 0;
}