摘要: sort()排序 从首地址 最后一个数地址的下一个如int a[6]={ 4,2,5,0,8,6};sort(a+1,a+5); 参加排序的数为 2 5 0 8qsort() 快速排序七种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类型) 阅读全文
posted @ 2011-11-19 20:38 快乐. 阅读(147) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3664DP代码三种情况dp[i][j]表示i个数中E为 j 的个数 加入第 i+1个数时 有三种情况 1.第 i+1个数放在最后 为dp[i-1][j] 2. i+1个数 和 a[i]>i的数交换 dp[i-1][j]*j 3.i+1个数和 a[i]<=i 的数交换dp[i-1][j-1]*[i-j] 则状态转移方程为 dp[i][j]=(dp[i-1][j]+dp[i-1][j]*j+dp[i-1][j-1]*(i-j))mod 1000000007;#include<iostream&g 阅读全文
posted @ 2011-11-19 19:55 快乐. 阅读(161) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3661贪心正排 倒排 相加代码#include<iostream>#include<algorithm>using namespace std;int a[1002],b[1002];int main(){ int N,T,i; while(scanf("%d%d",&N,&T)!=EOF) { int sum=0; for(i=1;i<=N;i++) scanf("%d",&a[i]); sort(a+1,a+N+ 阅读全文
posted @ 2011-11-19 19:45 快乐. 阅读(154) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3665最短路代码(spfa)#include<iostream>#include<cstdio>#include<string>#include<cstring>#define nMAX 12#define inf 1<<30using namespace std;int vs[nMAX],head[nMAX],dis[nMAX],sea[nMAX],qu[nMAX];int n,s_edge;struct Edge{ int u,v,w,nxt;} 阅读全文
posted @ 2011-11-19 19:38 快乐. 阅读(175) 评论(0) 推荐(0) 编辑