上一页 1 ··· 4 5 6 7 8
  2011年1月21日
摘要: 将原图与纸张按同样的方式放好,再通过长宽比例算缩小比例code:#include iostream#include cstdio#include cstdlibusing namespace std;int a, b, c, d, flag;double mark1, mark2;void cmp(int &a, int &b){ if(ab) { flag=a; a=b; b=flag; }}int main(){ while (scanf("%d%d%d%d",&a, &b, &c, &d), a && b && c && d) { cmp(a,b); cmp(c,d); m 阅读全文
posted @ 2011-01-21 23:29 FreeAquar 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 数学推论题,有胜负场的话,总分加3,平局总分加2,所以:平局数=3*总场数-总分数172k 0mscode:#include iostream#include cstdio#include stringusing namespace std;int main(){ int team, n; char name[20]; while(scanf("%d%d",&team, &n), team) { int sum=0, point, i=team; while(i--) { scanf("%s%d", name, &point); sum+=point; } printf("%d\n 阅读全文
posted @ 2011-01-21 22:19 FreeAquar 阅读(115) 评论(0) 推荐(0) 编辑
  2011年1月20日
摘要: 大数相乘,数组模拟code:#include iostream#include cstdio#include cstring#include stringusing namespace std;char a[50], b[50];int s[900], na[50], nb[50];int main(){ while(scanf("%s%s", a, b)!=EOF) { int al=strlen(a); int bl=strlen(b); memset(na,0,sizeof(na)); memset(nb,0,sizeof(nb)); memset(s,0,sizeof( 阅读全文
posted @ 2011-01-20 17:42 FreeAquar 阅读(373) 评论(0) 推荐(0) 编辑
  2011年1月1日
摘要: 在网上找了个公式。。。组合数学很强大。。。n&k==k 为奇数,否则为偶数开始n&k没加括号,wa了一次code:#include iostream#include cstdio#include cstdlibusing namespace std;int main(){ int n, k; while(scanf("%d%d", &n, &k)!=EOF) { printf("%d\n", (n&k)==k? 1: 0); } return 0;} 阅读全文
posted @ 2011-01-01 00:45 FreeAquar 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 题目自定义了一个算法,模拟就可以ACcode:#include iostream#include cstdio#include cstdlib#include cstringusing namespace std;char num1[15], num2[15];int main(){ while((scanf("%s%s", num1, num2))!=EOF) { int n1=strlen(num1); int n2=strlen(num2); int sum(0); for(int i=0; in1; i++) { for(int j=0; jn2; j++) { s 阅读全文
posted @ 2011-01-01 00:16 FreeAquar 阅读(147) 评论(0) 推荐(0) 编辑
  2010年12月31日
摘要: 类似二进制的转换,10120(skew) = 1 * (2^5-1) + 0 * (2^4-1) + 1 * (2^3-1) + 2 * (2^2-1) + 0 * (2^1-1) code:#include iostream#include cstdio#include cstdlib#include cstringusing namespace std;char str[20];int main(){ int sum, k, t; while(scanf("%s", str)) { if(str[0]=='0') break; sum=0; k=1; int m=strle 阅读全文
posted @ 2010-12-31 23:16 FreeAquar 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 筛法求素数code:#include iostream#include cstdio#include cstdlib#include cstring#define MAXN 35000using namespace std;bool prime[MAXN];void is_prime(){ int i, j; for(i=2; iMAXN; i++) { if(prime[i]==0) for(j=i+i; jMAXN; j+=i) prime[j]=1; }}int main(){ memset(prime, 0, sizeof(prime)); is_prime(); 阅读全文
posted @ 2010-12-31 22:16 FreeAquar 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 计算ip地址code:#include iostream#include cstdio#include cstdlib#include cstringusing namespace std;int bit[8]={128, 64, 32, 16, 8, 4, 2, 1};int main(){ int n, sum, i; char str[35]; while(scanf("%d", &n)!= EOF) { while(n--) { scanf("%s", str); sum=0; for(i=0; i32; i++) { if(str[i]=='1') sum+=bit 阅读全文
posted @ 2010-12-31 15:23 FreeAquar 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 练习输出code:#include iostream#include cstdio#include cstdlibusing namespace std;int factorial(int a){ if(a!=0 && a!=1) return a*factorial(a-1); else return 1;}int main(){ printf("n e\n- -----------\n"); double sum(0); for(int i=0; i10; i++) { printf("%d %.10g\n", i,sum+=1.0/factorial(i)); } retu 阅读全文
posted @ 2010-12-31 14:51 FreeAquar 阅读(134) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8