上一页 1 2 3 4 5 6 7 ··· 31 下一页
摘要: #include void bubble_sort(int a[],int n)//n为数组a的元素个数 { int i,j,temp; for(j=0;ja[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; ... 阅读全文
posted @ 2014-08-16 10:49 2014acm 阅读(117) 评论(0) 推荐(0) 编辑
摘要: #include void bubble_sort(int a[],int n)//n为数组a的元素个数 { int i,j,temp; for(j=0;ja[i+1]) { temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; ... 阅读全文
posted @ 2014-08-16 10:31 2014acm 阅读(153) 评论(0) 推荐(0) 编辑
摘要: for(i=1;i=i;j--) s 执行n-1次 当 i=2时,for(j=n;j>=i;j--) s 执行n-2次 ............. 当i=n-1时,for(j=n;j>=i;j--) s 执行1次 共执行 1+ 2+3+....+n-1=n*n/2次for(j=n;j>=i;j--... 阅读全文
posted @ 2014-08-15 13:09 2014acm 阅读(5128) 评论(0) 推荐(0) 编辑
摘要: for(j=1;j=0;i--) { b[j]=a[i]; j++; }数组a复制给b数组a有n个元素,数组b也是; 数组a中存放了n个数据; 程序前面需要将变量j赋初值0; 程序作用是将a中的数据按照倒序存放到数组b中,即b[0]=a[n-1]; b[1]=a[n-2]; ...; ... 阅读全文
posted @ 2014-08-15 13:08 2014acm 阅读(602) 评论(0) 推荐(0) 编辑
摘要: // 源程序2 DP#include int n,ans, a[1001],b[1001];int main(){ int i,j; scanf("%d",&n); for(i=1;ia[j]&&b[j]+1>b[i]) b[i]=b[j]+1; ans=1; for(i=1;i<=n;i++) i... 阅读全文
posted @ 2014-08-15 11:30 2014acm 阅读(80) 评论(0) 推荐(0) 编辑
摘要: #include #includeusing namespace std;struct node{ int l,w;}dp[1005];int g[1005][1005];int d[1005];int n,max_v;int f(int i){ if (d[i]>0) return d[i]; d... 阅读全文
posted @ 2014-08-15 11:23 2014acm 阅读(105) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusing namespace std;struct p{int a,b;};bool cmp(p p1, p p2){if(p1.b>p2.b) return true;if(p1.b==p2.b && p1.a>m;while(m-... 阅读全文
posted @ 2014-08-15 11:22 2014acm 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 公约数和公倍数时间限制:1000ms | 内存限制:65535KB难度:1描述小明被一个问题给难住了,现在需要你帮帮忙。问题是:给出两个正整数,求出它们的最大公约数和最小公倍数。输入第一行输入一个整数n(0 int gcd(int m,int n) { if(n==0) return m;... 阅读全文
posted @ 2014-08-13 22:42 2014acm 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 总提交:1728 测试通过:649描述输入两个正整数m和n(1int gcd(int m,int n){ if(n==0) return m; else return gcd(n,m%n);}int main(){ int x,y,t; while(scanf("%... 阅读全文
posted @ 2014-08-13 22:33 2014acm 阅读(436) 评论(0) 推荐(0) 编辑
摘要: #includeusing namespace std;struct point{ int x,y;};int main(){ point p,q; cin>>p.x>>p.y>>q.x>>q.y; cout<<p.x*q.y+p.y*q.x<<endl;} 阅读全文
posted @ 2014-08-13 21:50 2014acm 阅读(115) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 31 下一页