haha1235  

2013年10月5日

摘要: #include int main(void){ void pyramid(int n); pyramid(5); return 0;} void pyramid(int n) { int i,j; for(i=1;i<=n;i++){ for(j=1;j<=n-i;j++) printf(" "); for(j=1;j<=i;j++) printf("%d",i); putchar('\n'); } } 阅读全文
posted @ 2013-10-05 22:50 haha1235 阅读(117) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ void pyramid(int n); pyramid(5); return 0;} void pyramid(int n) { int i,j; for(i=1;i<=n;i++){ for(j=1;j<=n-i;j++) printf(" "); for(j=1;j<=i;j++) printf("%d",i); putchar('\n'); } } 阅读全文
posted @ 2013-10-05 22:43 haha1235 阅读(114) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ int i,j; int a[3][2]; for(i=0;i<3;i++) for(j=0;j<2;j++) a[i][j]=i+j; for(i=0;i<3;i++){ for(j=0;j<2;j++) printf("%4d",a[i][j]); printf("\n"); } return 0;} 阅读全文
posted @ 2013-10-05 20:38 haha1235 阅读(115) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ int i; int fib[10]={1,1}; for(i=2;i<10;i++) fib[i]=fib[i-1]+fib[i-2]; for(i=0;i<10;i++){ printf("%6d",fib[i]); if((i+1)%5==0) printf("\n"); } return 0;} 阅读全文
posted @ 2013-10-05 20:32 haha1235 阅读(105) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ char ch='w'; int a=2,b=0, c=0; float x=3.0; printf("%d",a&&b); printf("%d",a||b&&c); printf("%d",!a&&b); printf("%d",a||3+10&&2); printf("%d",!(x==2)); printf("%d",!x==2); pri 阅读全文
posted @ 2013-10-05 20:16 haha1235 阅读(108) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ char ch='w'; int a=2,b=3, c=1,d,x=10; printf("%d",a>b==c); printf("%d",d=a>b); printf("%d",ch>'a'+1); printf("%d",d=a+b>c); printf("%d",b-1==a!=c); printf("%d\n",3<=x<=5); return 0; 阅读全文
posted @ 2013-10-05 20:08 haha1235 阅读(101) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ int child,men,women; for(men=0;men<=45;men++) for(women=0;women<=45;women++) for(child=0;child<=45;child++) if(men+women+child==45&&men*3+women*2+child*0.5==45) printf("men=%d,women=%d,child=%d\n",men,women,child); return 0;} 阅读全文
posted @ 2013-10-05 19:47 haha1235 阅读(86) 评论(0) 推荐(0) 编辑
 
摘要: #include #includeint main(void){ int count,i,m,n; count=0; for(m=2;mn){ printf("%6d",m); count++; if(count%10==0) printf("\n"); } } printf("\n"); return 0;} 阅读全文
posted @ 2013-10-05 19:39 haha1235 阅读(84) 评论(0) 推荐(0) 编辑
 
摘要: #include #includeint main(void){ int count,i,m,n; count=0; for(m=2;mn){ printf("%6d",m); count++; if(count%10==0) printf("\n"); } } printf("\n"); return 0;} 阅读全文
posted @ 2013-10-05 19:31 haha1235 阅读(111) 评论(0) 推荐(0) 编辑
 
摘要: #include int main(void){ int i,j; double item,sum; sum=0; for(i=1;i<=100;i++){ item=1; for(j=1;j<=i;j++) item=item*j; sum=sum+item; } printf("1!+2!+...+100!=%e\n",sum);return 0;} 阅读全文
posted @ 2013-10-05 19:10 haha1235 阅读(190) 评论(0) 推荐(0) 编辑
 
摘要: #include double fact(int n);int main(void){ int i; double sum; sum=0; for(i=1;i<=100;i++) sum=sum+fact(i); printf("1!+2!+...+100!=%e\n",sum);return 0;}double fact(int n){ int i; double result; result=1;n; for(i=1;i<=n;i++) result= result*i; return result;} 阅读全文
posted @ 2013-10-05 19:03 haha1235 阅读(85) 评论(0) 推荐(0) 编辑
 
摘要: #include #includeint main(void){ int denominator,flag; double item,pi; flag=1; denominator=1; item=1.0; pi=0; while(fabs(item)>=0.0001){ item=flag*1.0/denominator; pi=pi+item; flag=-flag; denominator=denominator+2; } pi=pi*4; printf("pi=%.4f\n",pi); retur... 阅读全文
posted @ 2013-10-05 17:58 haha1235 阅读(100) 评论(0) 推荐(0) 编辑