摘要: #include<iostream>#include<stdio.h>#include<cstring>using namespace std;#define INF 5000000int a[201];int c[201][201];int d[201][201];int main(){ int n; int i,j,m,kk,k,p; int max1; scanf("%d",&n); int l; for(l=1;l<=n;l++) { memset(a,0,sizeof(a)); memset(c,0,sizeof( 阅读全文
posted @ 2011-05-16 23:30 Crazy_yiner 阅读(317) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>using namespace std;int main(){ int a[101]; int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=2;i<=n;i++) { int k=a[i]; int j=i-1; while(j>0&&a[j]>k) { a[j+1]=a[j]; j--; } a[j+1]=k; 阅读全文
posted @ 2011-05-16 23:29 Crazy_yiner 阅读(141) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>#include<cstring>using namespace std;int a[101],c[101];int num[100001],f[100001];int main(){int n,m;while(scanf("%d %d",&n,&m)!=EOF){if(n==0&&m==0)break;int sum=0;for(int i=1;i<=n;i++)scanf("%d",&a[i]);fo 阅读全文
posted @ 2011-05-16 23:28 Crazy_yiner 阅读(154) 评论(0) 推荐(0) 编辑
摘要: /**********************************有一定的钱 存在银行里给出可存的钱数 和相应利息第一年的利息会加入到第二年的本金中***********************************/#include<iostream>#include<stdio.h>#include<cstring>using namespace std;int d[50000],v[12],w[12];//数组开大了会超时int main(){ int n; //freopen("out.txt","w", 阅读全文
posted @ 2011-05-16 23:27 Crazy_yiner 阅读(218) 评论(0) 推荐(0) 编辑
摘要: /**//*用sort排string型的*/bool cmp(string s1,string s2){ if(s1.size()!=s2.size()) //如果长度不等按长度排 长度相等按字典序排 return (s1.size()<s2.size()); else return(s1<s2);//字典序}/**//*用sort排char型的*/bool cmp(char* a,char* b){ return strcmp(a,b)<0? true:false;} struct node{char array[100];}hehe[100];bool cmp(node 阅读全文
posted @ 2011-05-16 23:27 Crazy_yiner 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 1。qsort, 即快速排序, 包含在<cstdlib>或<stdlib.h>中,函数有四个参数, 没有返回值 下面是一个典型的写法:qsort(s,n,sizeof(s[0]),cmp);其中, s是需要排序的数组名, 也可以理解成开始地址, 因为你如果只需要对数组的部分排序的话, s可以写成&s[i]的形式的第二个参数n是参与排序的元素个数, 第三个参数是单个元素的大小,通常我们用sizeof()来获取大小, 因为它足够放心 绝对无毒^_^而且 很多时候我们需要对结构体进行排序的 你很难把握它的大小的~最后一个参数, 也就是我今天对着愣了很久的东东了 什么鸟 阅读全文
posted @ 2011-05-16 23:26 Crazy_yiner 阅读(775) 评论(0) 推荐(0) 编辑
摘要: 这题把前面两道题组合到了一起 判断最小生成树 和是否是一棵树#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int father[101];bool flags[101];struct country{ int first; int second; int value;}a[5001];bool cmp(country x,country y){ return x.value<y.value;}int ma 阅读全文
posted @ 2011-05-16 23:19 Crazy_yiner 阅读(311) 评论(0) 推荐(0) 编辑
摘要: 为了学习最小生成树 这两天学习了并查集 做并查集的题碰到了一道最小生成树 自己搞定了这道题 非常的高兴哈~#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int father[101];void makeset(int n){ for(int i=1;i<=n;i++) { father[i]=i; }}int findset(int x){ if(father[x]!=x) { father[x]=findset(father[x]); } retur 阅读全文
posted @ 2011-05-16 23:18 Crazy_yiner 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>#include<string.h>using namespace std;bool flags[1001];int father[1001];void makeset(int n){ for(int i=1;i<=n;i++) { father[i]=i; }}int findset(int x){ if(x!=father[x]) { father[x]=findset(father[x]); } return father[x];}void Union(int a,int b) 阅读全文
posted @ 2011-05-16 23:17 Crazy_yiner 阅读(189) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<stdio.h>using namespace std;int father[10000001],num[10000001];/**//*初始化数组*/void makeset(int x){ for(int i=0;i<=x;i++) { father[i]=i; num[i]=1; }}int findset(int x)//查{ if(x!=father[x]) { father[x]=findset(father[x]); }//回溯 return father[x];}void Union(int a 阅读全文
posted @ 2011-05-16 23:16 Crazy_yiner 阅读(207) 评论(0) 推荐(0) 编辑