C++
文章平均质量分 50
灬沿途有你灬
这个作者很懒,什么都没留下…
展开
-
常见排序算法(C++)
#include<iostream>using namespace std;void swap(int arr[],int i,int j){ int temp=arr[i]; arr[i]=arr[j]; arr[j]=temp;}void print(int arr[],int n){ for(int i=0;i<5;i++){ cout<<...原创 2019-11-19 15:14:17 · 91 阅读 · 0 评论 -
C++ 函数重载
函数重载本质上内部函数名字不一样。#include<iostream>using namespace std;//extern "C" 表示内部函数名字不被修改//extern "C" void print(int a[],int n)void print(int a[],int n){ for(int i=0;i<n;i++){ cout<<a...原创 2019-10-20 19:32:35 · 143 阅读 · 0 评论 -
C++引用
引用本质为指针。引用优势:1.修改形参,实参也被修改。2.提高效率。#include<iostream>using namespace std; int main() { double d=123.45; double& e=d;//引用必须初始化,必须用变量初始化,表示该变量的别名。 //等价为double* const E=&d;后面的e相当于*...原创 2019-10-20 19:08:08 · 131 阅读 · 0 评论 -
C++动态内存申请
#include<iostream>#include<cstdlib>#include<string>#include<new>using namespace std;//new类型==>(类型*)malloc(sizeof(类型)),动态内存使用。 int main() { string* p=static_cast<...原创 2019-10-20 16:09:47 · 411 阅读 · 0 评论 -
C++ bool类型,函数
#include<iostream>using namespace std; int main() { bool gender = true; bool sex =false; cout<<(gender?"帅哥":"美女")<<endl; cout<<(sex?"帅哥":"美女")<<endl; cou...原创 2019-10-20 15:30:10 · 2220 阅读 · 1 评论 -
C++ 类型检查
#include<iostream>using namespace std;#include<string>enum Course{UNIX,C,CPP,UC,VC};//枚举enum Color{BLACK,RED,GREEN,YELLOW,BLUE,THITE};struct Student{//结构 string name; Course co;};...原创 2019-10-20 15:28:26 · 953 阅读 · 0 评论 -
C++ 成员指针
#include<iostream>using namespace std;//结构变量.*成员指针,结构指针->*成员指针 来访问成员。struct date{//偏移量,相对地址, int year; int month; int day; void print(){cout<<year<<'-'<<month<<...原创 2019-10-20 14:39:39 · 114 阅读 · 0 评论