
C/C++
技术提高效率
技术提高效率,让工作更高效
展开
-
1.C/C++基础
1.交换a、b的值//交换a,b的值#includevoid swap1(int& a, int& b){int temp = a; //使用局部变量temp完成交换a = b;b = temp;printf("a=%d, b=%d\n",a,b);}void swap2(int& a, int& b){a = a + b; //使用原创 2017-05-26 15:48:18 · 683 阅读 · 0 评论 -
2.C/C++引用和指针
1.一般变量引用#include#includeusing namespace std;int main(){int a = 10;int b = 20;int &rn = a; //声明rn为变量a的一个引用int equal;rn = b; //将b的值赋值给rn。此时rn其实就是a的一个别名,对rn赋值 //其实就是对a的原创 2017-05-29 17:28:00 · 772 阅读 · 0 评论 -
7.C/C++排序
1.直接插入排序//1.直接插入排序#includeusing namespace std;void insert_sort(int a[], int n){ int i, j, temp; for (i = 1; i < n; i++) { temp = a[i]; for (j = i-1 ; j >= 0 && temp < a[j]; j--) { a[原创 2017-06-05 12:33:53 · 790 阅读 · 0 评论 -
4.C++面向对象
1.class与struct有什么区别C语言的struct与C++的class的区别:struct只是作为一种复杂数据类型定义,不能用于面向对象编程。C++中的struct和class的区别:对于成员访问权限以及继承方式,class中默认的是private的,而struct中则是public的。class还可以用于表示类模板,struct 则不行。2.原创 2017-06-01 14:26:09 · 708 阅读 · 0 评论 -
6.C/C++数据结构
1.单链表的各种操作#includeusing namespace std;//链表节点的定义typedef struct node{ int data; //节点内容 node *next;}node;//创建单链表node *create(){ int i = 0; //链表中数据的个数 node *head, *p, *q=NULL; int x =原创 2017-06-05 09:37:54 · 812 阅读 · 0 评论 -
3.C/C++字符串
1.不使用库函数将整数转换为字符串C语言提供了将几个标准库函数,可以将任意类型的(整形、浮点型、长整形)的数字转换为字符串itoa():将整形值转换为字符串 ltoa();将长整形转换为字符串 ultoa();将无符号长整形转换为字符串 gcvt();将浮点数转换为字符串,取四舍五入 ecvt();将双精度浮点数转换为字符串,转换结果中不包含十进制小数点 fcvt();原创 2017-05-31 19:38:12 · 1017 阅读 · 0 评论