- 博客(3)
- 收藏
- 关注
原创 关于字符串匹配问题的两种算法——算法笔记(1)
本人是算法初学者,记录下算法模板以及笔记心得,如有错误的地方欢迎指出。 1、KMP字符串 #include<iostream> using namespace std; const int N=1e6+10; char s[N],p[N];//p为模板字符串,s为子字符串 int ne[N];//模板串的next数组 int main() { cin>>p+1>>s+1;//从p[1]和s[1]开始读入字符串 //给模板串的next数组赋值的方式.
2022-01-14 21:23:07
378
46
原创 关于程序设计语言实习题目的题解
1、统计各年龄段人数。N个年龄通过调用随机函数获取,编写函数把0~9岁年龄段的人数放入数组下标[0]中,把10~19岁年龄段的人数放入数组下标[1]中,以此类推,把100~120岁年龄段的人数放入数组下标[10]中。 #include<stdio.h> #include<time.h> #include<stdlib.h> int a[100000]; int b[11]; int main() { int N; scanf("%d",&N); sr.
2021-12-27 23:02:21
6695
52
原创 快速排序及归并排序的模板
void quick_sort(int a[],int l,int r) { if(l>=r)return; int i=l-1; int j=r+1; int x=a[(l+r)/2]; while(i<j) { do(i++);while(a[i]<x); do(j--);while(a[j]>x); if(i<j)swap(a[i],a[j]); } quic.
2021-11-12 16:31:49
601
19
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人