VS学习日志Cpp基本数据类型以及操作C++

都在代码里面,说明注释很详细。
快捷键: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;
}	
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海宝7号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值