摘要: KMP算法主要工作是计算next数组(这里我们认为数组从0开始) 模式字符串为m,伪代码如下: void Next(m,next){ int i=0,j=-1; next[0]=-1; while(i<strlen(m)) { if(j 1||m[i]==m[j]) { i++; j++; next 阅读全文
posted @ 2020-03-15 23:56 kakusan 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 float a[10]; 3 float *p; 4 int main() 5 { 6 void input(float*,int); 7 void output(float*,int); 8 void change(float*,int); 9 p=a; 阅读全文
posted @ 2020-03-15 16:43 kakusan 阅读(891) 评论(0) 推荐(0) 编辑
摘要: 1 //利用二重指针实现改变指针数组和数组元素之间的mapping,并没有改变原数组 2 3 #include<stdio.h> 4 int a[5]; 5 int *name[]={&a[0],&a[1],&a[2],&a[3],&a[4]}; 6 int **p; 7 int main() 8 阅读全文
posted @ 2020-03-14 19:16 kakusan 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 1 //指针综合 2 # include<stdio.h> 3 int score[][4]={{60,70,80,90},{56,89,67,88},{34,78,90,66}}; 4 int* (*p)(int(*)[4],int); //指向函数的指针,函数返回类型为整型指针,函数有个指向整型 阅读全文
posted @ 2020-03-13 21:10 kakusan 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 1 //指向函数的指针变量做函数参数 2 # include<stdio.h> 3 int (*p)(int,int); 4 int a=5,b=6,c,d; 5 int main() 6 { 7 void fun(int,int,int(*p)(int,int)); 8 int max(int,i 阅读全文
posted @ 2020-03-13 15:09 kakusan 阅读(694) 评论(0) 推荐(0) 编辑
摘要: 基本结构: 类型 (*p)(形参列表); 1 //指向函数的指针变量 2 # include<stdio.h> 3 int (*p)(int,int); 4 int a=5,b=6,c,d; 5 int main() 6 { 7 int max(int,int); 8 int min(int,int 阅读全文
posted @ 2020-03-13 14:53 kakusan 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1 //字符串指针法赋值 2 # include<stdio.h> 3 char a[]="I am a student!"; 4 char b[20]; 5 char *p1=a,*p2=b; 6 int main() 7 { 8 while(*p2++=*p1++); //while(*b++= 阅读全文
posted @ 2020-03-12 18:44 kakusan 阅读(929) 评论(0) 推荐(0) 编辑
摘要: 输入 10个员工工号和姓名,以工号增加方式排序(姓名跟随改变),按工号查找(同时找出姓名) 代码如下: 1 # include<stdio.h> 2 # include<string.h> 3 char num[10][7]; 4 char name[10][10]; 5 char temp[10] 阅读全文
posted @ 2020-03-09 20:25 kakusan 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 代码如下: 1 // 统计一个字符串中单词个数和最长单词的位置以及最长单词的字母数,只考虑句子单词之间用空格分开的情况下 2 # include<stdio.h> 3 # include<string.h> 4 char c[100]; 5 struct S{ 6 int c1,c2,index; 阅读全文
posted @ 2020-03-09 15:30 kakusan 阅读(277) 评论(0) 推荐(0) 编辑
摘要: 代码如下: 1 //二次函数求解 2 # include<stdio.h> 3 # include<math.h> 4 float a,b,c; 5 struct d{ 6 double x1; 7 double x2; 8 }; 9 d R; 10 d func1(float,float,floa 阅读全文
posted @ 2020-03-09 12:58 kakusan 阅读(276) 评论(0) 推荐(0) 编辑