上一页 1 ··· 41 42 43 44 45

2010年11月16日

摘要: #include<stdio.h>int grade[7];void pubble(){ int _i,_j; int tmp; for(_i=0;_i<6;_i++) for(_j=_i;_j<6;_j++) if(grade[_i]>grade[_j]) { tmp=grade[_i]; grade[_i]=grade[_j]; grade[_j]=tmp; }}int sum(){ int _j; int max=0; for(_j=1;_j<5;_j++) max+=grade[_j]; return max;}int... 阅读全文
posted @ 2010-11-16 21:06 yming0221 阅读(91) 评论(0) 推荐(0)
摘要: Is It A Tree?Time Limit:1000MSMemory Limit:10000KTotal Submissions:9821Accepted:3354DescriptionA tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties.There is exac 阅读全文
posted @ 2010-11-16 20:07 yming0221 阅读(86) 评论(0) 推荐(0)

2010年11月15日

摘要: 食物链Time Limit:1000MSMemory Limit:10000KTotal Submissions:19801Accepted:5655Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句 阅读全文
posted @ 2010-11-15 16:43 yming0221 阅读(157) 评论(0) 推荐(0)
摘要: POJ 1287NetworkingTime Limit:1000MSMemory Limit:10000KTotal Submissions:2924Accepted:1579DescriptionYou are assigned to design network connections between certain points in a wide area. You are given a set of points in the area, and a set of possible routes for the cables that may connect pairs of p 阅读全文
posted @ 2010-11-15 14:06 yming0221 阅读(144) 评论(0) 推荐(0)

2010年11月14日

摘要: #include<stdio.h>#defineMAX30000intf[MAX];//这里的1001只是一个示意性的数字代表初始状态下的分支数目intr[MAX];intflag;//由于不知道应该将子树挂到那个集合上面去,故需要一个准则,这里的准则是将子树挂到//r值大的集合上面去,初始状态下r数组的值均为一,代表每个分支下只有一个数字intfind(intn){if(f[n]==n)returnn;elsef[n]=find(f[n]);returnf[n];}//查找函数,并压缩路径intUnion(intx,inty){inta=find(x);intb=find(y); 阅读全文
posted @ 2010-11-14 21:21 yming0221 阅读(134) 评论(0) 推荐(0)
摘要: qsort函数应用大全(转)七种qsort排序方法<本文中排序都是采用的从小到大排序>一、对int类型数组排序int num[100];Sample:int cmp ( const void *a , const void *b ){return *(int *)a - *(int *)b;}qsort(num,100,sizeof(num[0]),cmp);二、对char类型数组排序(同int类型)char word[100];Sample:int cmp( const void *a , const void *b ){return *(char *)a - *(int *)b 阅读全文
posted @ 2010-11-14 11:06 yming0221 阅读(107) 评论(0) 推荐(0)
上一页 1 ··· 41 42 43 44 45

导航