上一页 1 ··· 24 25 26 27 28
摘要: #include<stdio.h>int sum(int i){int k=0;while(i){k+=i;i--;}return k;}int main(){int a;while(1 == scanf("%d",&a))printf("%d\n\n",sum(a));return 0;} 阅读全文
posted @ 2012-03-15 12:27 ZH奶酪 阅读(273) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>int main(){int a,b;while(2 == scanf("%d%d",&a,&b))//学到了这个~printf("%d\n",a+b);return 0;} 阅读全文
posted @ 2012-03-15 12:26 ZH奶酪 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>int main(){ char a[1000],b[1000]; int c[1005]; char ch; int len_a,len_b; int idx_c,len_c; int sum; int i,j; len_a = 0; len_b = 0; scanf("%d",&sum); //读取数据 for(j=0 ; j<sum ;j++) { //读取缓存区数据 memset(c,0,sizeof(int)*... 阅读全文
posted @ 2012-03-14 23:01 ZH奶酪 阅读(1019) 评论(0) 推荐(0) 编辑
摘要: 求解最大子序列的和。首先子序列的起始元素不一定是从第一个元素开始的。开始的时候,用的是暴力破解。。。总是TLE。。。后来在网上找到了参考的公式是:s[1] = a[1];s[n] = s[n-1]>=0?s[n-1]+a[n]:a[n];貌似是一种动态规划,和以前做的背包问题有些类似#include <stdio.h>int data[100000];int main(){ int i,j,k,l,sum,b,e,max=0,t; scanf("%d",&i); for (j=1;j<=i;j++) { max = -100000; scan 阅读全文
posted @ 2012-03-14 22:59 ZH奶酪 阅读(1588) 评论(2) 推荐(1) 编辑
上一页 1 ··· 24 25 26 27 28