- 博客(33)
- 资源 (1)
- 收藏
- 关注
原创 sdut1585 求素数的个数
ben#include #include #include int a[1008]; int main() { int n,i,j; int sum; scanf("%d",&n); sum=0; memset(a,1,sizeof(a)); for(i=2; i
2014-08-29 20:39:36
443
原创 SDUT 1480 哈希,找次数最多且数最小的
#include #include struct node { int time; int data; struct node *next; }*head[100000];//多个链表存放 int main() { int i,maxtime=-1,maxshu=-1,n; int a,b,c
2014-08-28 20:22:30
478
原创 KMP字符串匹配,字串
//当主串中第i个字符与模式中第j个字符“失配”时, //主串中第i个字符应该与模式中哪个字符再比较。 #include #include #include char str1[1000000],str2[1000000]; int next[1000000]; void getnext(int t)//next[j]表示当模式中第j个字符与主串中相
2014-08-28 16:47:22
415
原创 知道先序和中序,求后序以及层次遍历
#include #include #include char a[100000],b[100000]; struct node { char data; struct node *l,*r; }; struct node *creat(char *a,char *b,int n)//重建树 { if(
2014-08-27 20:58:48
852
原创 SDUTOJ2118 链表逆置
view plaincopyprint如果您复制代码时出现行号,请点击左边的“view plain”后再复制#include #include #include struct node { int data; struct node *next; }*head; int main() {
2014-08-27 15:42:16
439
原创 SDUT2040 快排与二分查找
view plaincopyprint如果您复制代码时出现行号,请点击左边的“view plain”后再复制#include #include #include int q[100008]; int fh(int s,int t) { int key; key=q[s]; while(s {
2014-08-27 11:06:09
434
原创 最短路,几种做法
题意是#include #include #include #define M 999999int map[205][205];int vis[205],dis[205];int n,m;int s,t;void bellmanford()//美国数学家理查德•贝尔曼(Richard Bellman, 动态规划的提出者)和小莱斯特•福特(Lester Ford)发明{
2014-08-26 16:03:43
522
原创 已经写了好久了,都快要忘记啦
Description众所周知,英语四六级考试有几套不同的试卷,而且,为了防止我们抄袭旁边同学的,一般附近同学的试卷和你的试卷不一样。但是,我们还是知道了一些同学的试卷是相同的,假设有n个同学,编号为0~n-1,你的编号为0,,根据我们已知的信息,求还有多少人的试卷和你的试卷是相同的。Input多组输入,每组第一行,有两个整数n,m(2 接下来m行,每行有两个整
2014-08-25 21:18:25
384
转载 最小生成树,转别人的
最小生成树即最小权重生成树,主要适用于 N个点之间 构造N-1线路,使N个点之间任意两点之间都可到达,但是N个点之间 不构成回路,并且这N-1条线路的权重之和最小即 消耗最小。注意:在构造最小生成树,加入新的节点时,不仅要保证权重最小,首要条件是 不能构成回路。以图示为例,构造最小生成树(一)普里姆 以下步骤
2014-08-25 21:15:57
407
原创 要谨记遇到小数点,要用double,不能先用double
#include #include #include #include #define M 999999double map[105][105];int vis[105];double dis[105];int n,m;double sum;struct node{ int x,y;} p[105];void prim(){ int i,j,flag;
2014-08-25 20:08:39
1217
原创 做的最小生成树第二个题,以为不对呢,谁知交上就AC啦
Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本。现请你编写程序,计算出全省畅通需要的最低成本。 Input测试输入包含若干测试用例。每个测试用例的第1行给出评估的道路条数 N、村庄数目M (
2014-08-25 15:38:56
461
原创 嗯嗯,算原创吧,把模板改了一下
#include #include #include #define M 999999int map[110][110];int vis[110],dis[110];int sum;int n,m;void prim(){ int i,j; int flag; int min; memset(vis,0,sizeof(vi
2014-08-25 15:15:09
486
原创 搞不懂啊,为什么会这样,连结果都输不出来,怎么就AC了呢?
DescriptionA prefix of a string is a substring starting at the beginning of the given string. The prefixes of "carbon" are: "c", "ca", "car", "carb", "carbo", and "carbon". Note that the empty s
2014-08-23 20:04:35
529
原创 错了两次,就是知先序和中序求后序的,但是不能用字符串,因为输入中间有空格,输出也有空格
#include #include #include int a[1005],b[1005];int c[1005],s;struct node{ int data; struct node *l,*r;};struct node *build(int *a,int *b,int t){ struct node *root;
2014-08-23 08:50:09
377
原创 已知先序和中序求后序
#include #include #include char str1[100],str2[100];struct node{ char data; struct node *l,*r;};struct node *build(char *str1,char *str2,int s){ int i; struct node
2014-08-22 11:08:28
721
原创 二叉树 中序,后序,叶子节点,深度
#include #include int numleaf=0;int numdepth;struct node{ char data; struct node *l,*r;};struct node *build(struct node *root){ char a; a=getchar(); if(a==',')
2014-08-22 09:47:43
681
原创 背包,特基本,一开始却非常迷惑
#include #include #include int t,N;int max(int x,int y){ return x>y?x:y;}int main(){ int i,j; int w[3]={150,200,350}; int c[3]={150,200,350}; int f[10005];
2014-08-21 11:00:43
555
原创 加密字符串,栈
Input 输入数据的第一行为一个正整数T(T≤30),表示共有T 组测试数据。接下来T 行,每行为一个字符串,字符串仅包含小写英文字母,且保证原始字符串中不包含相邻两个相同的字母,字符串长度不超过200000。Output 每组数据输出一行字符串,表示还原后的内容。Sample Input1ssilofaa
2014-08-21 09:47:57
438
原创 用的循环链表
#include #include #include #define SE struct E *#define SE1 struct Estruct E{ int data; struct E *next;}*head;int main(){ int i,j; struct E *p,*q,*r; head=(SE)malloc(sizeo
2014-08-21 09:39:58
413
原创 进制转换
#include #include #include #include char a[10000000];int main(){ int n,z,m,x,i,j,f; int r; while(~scanf("%d %d",&n,&r)) { i=0; memset(a,0,sizeof(a)); f=n;
2014-08-21 09:39:13
331
原创 01背包,最基础的,看着模板敲的,交上还错了5次,不懂为什么用C交就不对呢。还是不懂
#include #include #include int f[10005];int v[10005],w[10005];int max(int x,int y){ return x>y?x:y;}int main(){ int i,j; int t,n,V; scanf("%d",&t); while(t-
2014-08-20 20:48:48
403
原创 VJ --2056,循环链表,当5个人循环时,要循环到4
Description说到“敢死队”,大家不要以为我来介绍电影了,因为数据结构里真有这么道程序设计题目,原题如下: 有M个敢死队员要炸掉敌人的一个碉堡,谁都不想去,排长决定用轮回数数的办法来决定哪个战士去执行任务。如果前一个战士没完成任务,则要再派一个战士上去。现给每个战士编一个号,大家围坐成一圈,随便从某一个战士开始计数,当数到5时,对应的战士就去执行任务,且此战士不再参加下一轮
2014-08-19 20:33:51
645
原创 VJ---链表训练,查找,输出前一个和后一个
#include #includestruct B{ int date; struct B *next;}*head;int main(){ int n,m,i,j,a; struct B *p,*q,*r; head=(struct B *)malloc(sizeof(struct B)); head->next=NULL; p
2014-08-19 17:13:31
325
原创 VJ -链表训练--要记住啊!插入是:r->next=pa->next; pa->next=r;不能再错啦!!
#include #include #include struct A{ int data; char name[100]; struct A *next;}*head;int main(){ int n,m,k=0; struct A *p,*r,*pa; head=(struct A *)malloc(si
2014-08-19 17:11:00
1099
原创 建有序链表,还是要打好基础的。。。
#include#include#define SK struct K *struct K{ int date; struct K *next;}*head;int main(){ int n,t; struct K *p,*r,*q,*pa; head=(SK)malloc(sizeof(struct K)); head->next=
2014-08-19 10:48:41
762
原创 VJ--图论---BFS搜索啊搜索,又改了好久,原因是:首先是第一个忘记标记啦,后来又发现队列开小啦,各种错啊!!
#include #include #include char map[105][105];int vis[105][105];int mv[8][2]= {{1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1}};int s;int m,n;struct A{ int x; int y;} p[10050];
2014-08-19 10:44:34
501
原创 sdut OJ2141---图论--用的数组+BFS
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#include #include #include int map[105][105];in
2014-08-18 19:55:59
398
原创 sdutOJ 2142 --图论--用的是链表+BFS ---改了好久,都是小毛病,粗心啊!!!
#include #include #include #define SH struct H *#define SH1 struct Hint n,k,m,t;int vis[105];int s[105];struct H{ int data; struct H *next;}*head[105];void getline(int
2014-08-18 19:51:25
333
原创 VJ 并查练习
题目描述:#include #include int set[10005];int num[10005];int max;int jihe(int x){ int r; r=x; while(r!=set[r]) { r=set[r]; } int k,y=x; while(
2014-08-16 09:52:04
541
转载 OJ 2779找朋友 BFS
题目描述:#include #include #include struct node{ int x,y,ans;} q[500];int vis[16][16];int mv[4][2]= {{0,1},{1,0},{-1,0},{0,-1}};char map[16][16];int n,m;void BFS(int x,int y){
2014-08-12 15:24:46
400
原创 OJ 2135用的数组
题目描述:Description中午买饭的人特多,食堂真是太拥挤了,买个饭费劲,理工大的小孩还是很聪明的,直接奔政通超市,哈哈,确实,政通超市里面也卖饭,有好几种菜,做的比食堂好吃多了,价格也不比食堂贵,并且买菜就送豆浆,吸引了不少童鞋。所以有时吧,人还是很多的,排队是免不了的,悲剧的是超市只有两个收银窗口。问题是这样的:开始有两队人在排队,现在咱们只研究第一队,现在我们给
2014-08-11 20:43:38
358
原创 栈和队列B题
#include #include #include int main(){ int t,i; int a[100000]; char str[10]; while(~scanf("%d",&t)) { i=1; while(t--) { sca
2014-08-11 15:49:53
379
过程建模与控制课件pdf
2018-09-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人