![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构和算法
peacentury
这个作者很懒,什么都没留下…
展开
-
KMP(整数匹配)
http://acm.hdu.edu.cn/showproblem.php?pid=1711看了 严蔚敏老师讲解的KMP算法后,想找个题做一下,听的时候,感觉还行,可是做起题来还是有点问题,特别是next数组的取值,自己参考着写一直没有过,后来看了下别人的资料,next[0]从-1开始取值就AC了,看来next函数的取值还是比较重要,理解还是不够。。。。#include#define原创 2012-03-28 10:56:38 · 378 阅读 · 0 评论 -
simple Joseph
#include#define MAX 5000using namespace std;void Joseph(int n,int m){ int person[MAX]; for(int i=1;i<=n;i++) person[i]=1; int k,cnt; k=cnt=0; for(int i=1;i<=n;i++) { if(person[i]==1) {原创 2012-04-09 19:50:25 · 243 阅读 · 0 评论 -
简单的结构体二级排序
#includeusing namespace std;typedef struct{char name[20];int subnum;char sub[100][20];int mark[100];int totalmark;}Student;Student student[70];int cmp(const void *a,const void *b){Stud原创 2011-12-09 21:24:13 · 432 阅读 · 0 评论 -
大整数加法
http://acm.hdu.edu.cn/showproblem.php?pid=1002刚开始接触oj时,了解比较少,感觉这种题还比较麻烦。。。新手代码:#include#includeusing namespace std;int main(){ int T,i,j,t,sum[1000],s1,s2,k,flag; char A[1000],B[1000],原创 2012-03-28 10:40:55 · 303 阅读 · 0 评论 -
关于螺旋三角形和螺旋正方形的输出表示
今天遇到了输出顺时针输出螺旋三角形的问题,花了点时间写了一下。于是,又想到了逆时针输出的情况,最后又想试着输出正方形的顺时针和逆时针10 1 2 3 4 5 6 7 8 9 10 27 28 29 30 31 32 33 34 11 26 45 46 47 48 49 35 12 25 44 54 55原创 2012-03-27 23:21:29 · 1580 阅读 · 0 评论 -
二分查找
There are m positive integers in set S.can we find two elements in set s and the sum of them equal to X?Input The first line of the input file contains a single integer n(the number of test原创 2012-03-28 23:01:25 · 320 阅读 · 0 评论