c++基础语法(复习)/遍历概念(在最后)

1c+输入输出头文件

.#include <iostream>

#include <iostream>
using namespace std;
int main()
{
cout<<"hello world!"<<endl;
return 0;
}


-----------------------
2.数据类型

int number = 1;
char character='a';
bool blloean=true;//or false
char* aaa="hello";
string cppstring="world";


3。输出
 

cout<<number<<endl;//1
cout<<character<<endl;//a
cout<<boolean<<endl;//1
cout<<cstring<<endl;//hello
cout<<cppstring<<endl;//world;

4.输入
(1)终端输入单个元素;

int a;
cin>>a

;
(2)终端输入一行

 <1>getline(cin, b);//将输入的一行都读到字符串b里(不用写长度)
<2>char str[100];
      cin.getline(str,100);//第一个参数是个字符指针


5.c++语法类型--bool

bool yes=true;
if(yes){
 puts("yes")
}
else{
puts("no");
}


6.c++----动态开辟内存

int* number=new int;
int* arr=new int[100];
int* carr =(int*)malloc(100*sizeof(int));

7.函数重载
定义:两个函数可以名字相同,但参数列表和返回值不同;

int add(int a,int b){
return a+b;
}
int add(int a){
return a;
}
int add(int a,int b=0){      //这里b=0代表如果b没有赋值,默认为0,赋值了按赋值的算
return a+b;
}


8.结构体声明

struct node{
int number;
note* next;
};
node* head;


9.遍历的概念
比如:一堆盒子中,其中有些盒子里有糖,要知道总共有多少糖,我们要打开每个盒子去看一下,这就是遍历。
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值