C++ 数据类型,数组和函数


#define  _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<stdio.h>
#include<string>

using namespace std;

int main()
{
	//单行注释
	//多行注释

	//变量
	//变量创建的语法: 数据类型  变量名 =  变量初始值

	//常量
	//C++ 定义常量方法
	//#define	宏常量
	//#define Date 5;
	//const 修饰
	//const int month 

	//标识符(变量,常量)
	//标识符命名规则

	//错误写法:
	//int int a=45;
	//int 123abs = 45;

	//数据类型

	//整形	short	 int	long	long long  
	//		2^15	2^31	2^31		2^61

	//关键字 sizeof(数据类型 / 变量);


	//实数型(浮点型 )
	//float		单精度
	//double	
	//float f1 = 3.1415926f;
	//cout << f1 << endl;
	//double f2 = 3.1415926;
	//cout << f2 << endl;
	//float f3 = 3e-2;
	//cout << f3 << endl;

	//字符型	ASCII 编码 a--97	A--65		''		
	//char	
	char a1 = 'a';
	cout << a1 << endl;
	cout << (int)a1 << endl;

	//转义字符
	//换行符 \n
	//		 \\
	//		 \t		水平制表符
	//		 

	//字符串型
	//char a2[] = "abcdfg";
	//cout << a2 << endl;

	//string a3 = "ajsidh";
	//cout << a3 << endl;


	//	布尔类型	bool
	//	true   false    1bit


	//布尔数据类型		bool
	//  true false  1bit
	// 
	//数据的输入
	//cin

//	1.整形

//  2.浮点型
	//int f = 3.14f;
	//cout << "请给形变量赋值: " << endl;
	//cin >> f;
	//cout << "浮点型变量" << f << endl;
	//
//	3.字符型
//
//
//	4.字符串型
	//string str = "hello word!!!";
	//cout << "" << endl;
	//cin >> str;
	//cout << str << endl;


	//5.布尔类型

	//bool flag = false;
	//cout << "请输入---" << endl;
	//cin >> flag;
	//cout << "布尔类型flag = " << flag << endl;


	//运算符

//	算术运算符		
//	+	-	*	/	%	++	--	
//  赋值运算符
//	=	+=	-=	/=	%=	*=
//  比较运算符
//	==	!=	  >  	<    >= 	<=	
//  逻辑运算符
//	!非		&& 与		||	或




//	程序流程结果

//	顺序结构
//	
//  选择结构
//		if--else		if--else if--else		()=()?():()
/* 						switch (switch_on)
						{
						case (case_on):
						default:
							break;
						}
*/
//	循环结构
//	while ()		do--while()	
//

	int a = 10;
	int b = 0;
	(a < b ? a : b) = 100;
	cout << "a=" << a << endl;
	cout << "b=" << b << endl;

	
//	跳转语句		break		continue		goto
	
	//
	//int t = 10;

	//FLAC:

	//for (int i = 0; i < 100; i++)
	//{
	//	if (i % 2 == 0)
	//	{
	//		continue;
	//	}
	//	cout << i << " ";
	//}
	//cout << endl;
	//
	//t--;
	//if (t > 0)
	//{
	//	goto FLAC;
	//}

	system("pause");


	

//	数组


	//1 数组类型   数组名 [数组长度]
	int arr[3];

	arr[0] = 1;
	arr[1] = 2;
	arr[2] = 3;

	cout << arr[0] << endl;

	//2 数组类型  数组名[数组长度] = { 值1,  值2,  值3,  值4 };


	//3 数组类型  数组名[  ] = { 值1,  值2,  值3,  值4 };

 
	//数组名用途

	//1 统计整个数组占用内存大小
	int aar[10] = { 0,1,2,3,4,5,6,7,8,9 };
	cout << sizeof(aar) << endl;

	//2  首元素地址

	cout << "数组首地址:" << aar << endl;  //十六进制
	cout << "数组首地址(十进制):" << (int)aar << endl;
	cout << "数组第一个元素地址:" << &aar[0] << endl;
	cout << "数组第二个元素地址:" << &aar[1] << endl;

	//数组名是常量



	//冒泡排序		忽略

	//二维数组

	//函数

	//函数定义

	//返回值类型	函数名	  函数列表
	//函数语句
	//返回语句

	//函数调用
	//函数调用语法 函数名称(名称)
	
		



	return 0;
}


以上是看课笔记

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值