
C/C++
文章平均质量分 58
千年的塔
Go语言和MySQL技术专家,著有《Go语言核心编程》一书。
展开
-
归并排序 C语言数据结构
#include #include #define N 10void merge(int *a1,int a1_start,int *a2,int a2_start, int a2_end,int *a3,int a3_start,int a3_end); void merge_sort(int *a,int left,int right);/*原创 2008-08-20 09:49:00 · 2788 阅读 · 0 评论 -
C printf 格式输出字符串
s格式符:用来输出一个字符串。 %s 用来输出一个字符串,不含双引号. 例:printf("%s","CHINA"); %ms m指定宽度(字符串长度小于m时左补空格,大于时按实际宽度输出) %-ms 左对齐,不足m时右补空格 %m.ns 输出占m列,只取字符串中左端n个字符.这n各字符输出在m列的右侧,左补空格. %-m.ns 同上,右补空格int _tmai转载 2013-01-23 08:36:57 · 12150 阅读 · 0 评论 -
strlen 与 sizeof 区别
1.函数类型#include size_t strlen(const char *s);size_t sizeof()2.本质区别本质上,strlen是函数,而sizeof是运算符。strlen需要进行一次函数调用,而对于sizeof而言,因为缓冲区已经用已知字符串进行了初始化,起长度是固定的,所以sizeof在编译时计算缓冲区的长度,sizeof后如果是类转载 2012-10-14 15:52:37 · 776 阅读 · 0 评论 -
选择排序 --C语言数据结构
#include #include void swap(int *p1,int *p2);void select_sort(int *a,int n);/*函数功能:使用选择排序法进行排序:从小到大; 函数原型:void select_sort(int *a,int n) 函数参数:int *a:数组名 int n :排序元素数 函数返回值:void 作者 : 李文塔原创 2008-08-20 09:45:00 · 2398 阅读 · 4 评论 -
二叉树排序 --C语言数据结构
#include #include typedef struct btree{ int data; struct btree *left; struct btree *right; }BTR,*PBTR;typedef struct BTRSt{ PBTR ptree; struct BTRSt *link;}Stack,*PStack;PBTR Bitree=NULL;/*函数原创 2008-08-20 09:48:00 · 3420 阅读 · 0 评论 -
基数排序 C语言数据结构
#include #define N 10/*函数功能:求一个整数的第K位的值 函数原型:int digitk(int no,int k)函数参数:函数返回值:返回数据的位数 作者 : 李文塔 Wenta Li 日期: 2008年5月21日 11:19 */int digitk(int no,int k){ int i,j,m; if(k==0) { return no%10原创 2008-08-20 09:44:00 · 2332 阅读 · 4 评论 -
冒泡排序 C数据结构
#include #include void swap(int *p1,int *p2);void bubble_sort(int *a,int n);/*函数功能:使用冒泡法进行排序:从小到大; 函数原型:void bubble_sort(int *a,int n) 函数参数:int *a:数组名 int n :排序元素数 函数返回值:void 作者 : 李文塔 W原创 2008-08-20 09:42:00 · 6298 阅读 · 0 评论 -
快速排序----C语言数据结构
#include #include void swap(int *p1,int *p2);void quick_sort(int *a,int left,int right);/*函数功能:使用快速排序法进行排序:从小到大; 函数原型:void quick_sort(int *a,int left,int right) 函数参数:int *a:数组名 int left:排原创 2008-08-20 09:37:00 · 2681 阅读 · 0 评论 -
交换排序 --C语言数据结构
#include #include void swap(int *p1,int *p2);void bubble_sort(int *a,int n);/*函数功能:使用交换法进行排序:从小到大; 函数原型:void swap_sort(int *a,int n) 函数参数:int *a:数组名 int n :排序元素数 函数返回值:void 作者 : 李文塔 Wen原创 2008-08-20 09:51:00 · 1213 阅读 · 0 评论 -
C 指针阅读与定义
一.阅读指针 1.明确优先级: (p) > p[]数组、p()函数 > *p 括号的优先级最高,其次是数组和函数结合最后才是 * 2. 采用逐步替代法 示例: int *( *( *a[5]) ( ) ) ( ); 1.a是数组,数组里5个元素,数组中存放的是指针,迭代替换int *( *(P)原创 2013-03-15 16:03:08 · 804 阅读 · 0 评论