初始化
do{
}while(判断);
int scores[]={123,5,6,8,4,25,69}
for(int temp:scores){
cout<<temp;scores
}
for 使用定义临时变量temp 读取数组里的每个yuan's
初始化
do{
}while(判断);
int scores[]={123,5,6,8,4,25,69}
for(int temp:scores){
cout<<temp;scores
}
for 使用定义临时变量temp 读取数组里的每个yuan's
#define 宏的名字 字符串
tyoedef 类型名(string int float) 别名 ;
初始化:
while(判断){
循环体;
更新;
}
int i=0;
while(i<10){
cout<<"asdsa"
i++;
}
a+=b a=a+b
strcmp(字符串1,字符串2)
比较字符串里的字符
0相等 非零 不等
string 字符串1="asd";
string 字符串2="asd";
(字符串1==字符串2)
string类型的字符串可以直接比较
for(初始化 ;判断是否执行循环; 更新 ){
循环体
}
for(int i=0: i<10; i=i+1 ){
循环
}
#include<array>
array<数组类型(int),大小> a1={2,8,654,48,89};
array 可以直接互相赋值
例
array<int,8> a1={2,8,654,48,89};
array<int,8> a2;
a2=a1;
int * p = new int[20];
把P赋成数组
delete[ ]p;
才能delete掉new[ ]p出来的shu'z
int * p = new int;
*p = 100;
声明一个新的整数类型区域 赋值
delete p;
new出来必须通过delete释放
int * p1=NULL;
int * p2=0;
int * p3 =nullptr;
都是指向空指针
void * p (p可以接受任意类型的地址)
int * a;
p=&a;
cout<<*((int*)p)
int a=10;
int * pa =&a;
定义指针pa类型
cout<<*pa
读取指针pa的值
& 取得一个变量的内存地址
int a=10;
cout<<&a;
输入内存地址
*从内存地址中取得数据
cout<<*(&a);
enum 名字{
Tank,
Magic,
ADC,
Assist
};
名字 heroType=Tank;
struct 结构体名字{
float x;
float y;
float z;
}
结构体名字 某东西名字{1,5,6} 分别赋值
就可以调用结构体
cout<<赋值东西名字.x 输出某个值
结构体名字 某些东西的数组[ ]{ {1,2,3 },{5,6,5 },{ 8,9,4},{ 5,6,7} };
结构体类型数组
cout<<某东西数组[1].x<<某东西数组[1].y<<某东西数组[1].z
输出jie'g
string 声明一个字符串
cout<<字符串[n]
可以访问里面某一位字符
字符串1="baidu"
字符串2=".com"
string s=字符串1+字符串2
(string可用于加法)
cout<<字符串.size()
可查看字符串的个数
字符串1+=字符串2
字符串1=字符串1+字符串2
getlinw(cin,字符串)
接受输入整行字符串
cin.getline(数组,长度)
读取整行shu
char website[]{'b','a','i','d','u','\0'};
char website[]="baidu";
cout<<strlen(website) 查看字符串chang'd
**Array[n] 数组
float
double
long double
浮点类型 小数
const int j=90 变成常量 不会再bian
bool 只有 true和false