摘要: #includeint main(void){ int number; printf("Enter a number:"); scanf("%d",&number); if(number%2==0){ printf("The number is even.\n"); } else{ printf("The number is odd.\n"); } return 0;} 阅读全文
posted @ 2013-10-02 20:33 zhaoyang16 阅读(149) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int mynumber=38; int yournumber; printf("Input your number:"); scanf("%d",&yournumber); if(yournumber==mynumber) printf("Ok!you are right!\n"); else if(yournumber>mynumber) printf("Soory!your number is bigger than my number!\n"); 阅读全文
posted @ 2013-10-02 20:32 zhaoyang16 阅读(163) 评论(0) 推荐(0) 编辑
摘要: #includedouble fact(int n);int main(void){ int i,n; double result; printf("Enter n:"); scanf("%d",&n); for(i=0;i<=n;i++){ result=fact(i); printf("%d!=%.0f\n",i,result); } return 0;}double fact(int n){ int i; double product; product=1; for(i=1;i<=n;i++){ produc 阅读全文
posted @ 2013-10-02 20:31 zhaoyang16 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #include#includeint main(void){ int i,n; double power; printf("Enter n:"); scanf("%d",&n); for(i=0;i<=n;i++){ power=pow(2,i); printf("pow(2,%d)=%.0f\n",i,power); } return 0;} 阅读全文
posted @ 2013-10-02 20:30 zhaoyang16 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int i,n; double product; printf("Enter n;"); scanf("%d",&n); product=1; for(i=1;i<=n;i++){ product=product*i; } printf("product=%.0f\n",product); return 0;} 阅读全文
posted @ 2013-10-02 20:29 zhaoyang16 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int denominator,flag,i,n; double item,sum; printf("Enter n:"); scanf("%d",&n); flag=1; denominator=1; sum=0; for(i=1;i<=n;i++){ item=flag*1.0/denominator; sum=sum+item; flag=-flag; denominator=denominator+2; } printf("sum=%f\n",sum); retur 阅读全文
posted @ 2013-10-02 20:28 zhaoyang16 阅读(137) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int i,n,sum; printf("Enter n:"); scanf("%d",&n); sum=0; for(i=1;i<=n;i++){ sum=sum+i; } printf("Sum of numbers from l to %d is %d\n",n,sum); return 0;} 阅读全文
posted @ 2013-10-02 20:27 zhaoyang16 阅读(121) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){int fahr,lower,upper;double celsius;printf("Enter lower:");scanf("%d",&lower);printf("Enter upper:");scanf("%d",&upper);printf("fahr celsius\n");for(fahr=lower;fahr<=upper;fahr++){ celsius=(5.0/9.0)*(fahr-32); printf 阅读全文
posted @ 2013-10-02 20:25 zhaoyang16 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #include#includeint main(void){ int money,year; double rate,sum; printf("Enter money:"); scanf("%d",&money); printf("Enter year:"); scanf("%d",&year); printf("Enter rate:"); scanf("%lf",&rate); sum=money*pow(1+rate,year); printf 阅读全文
posted @ 2013-10-02 20:24 zhaoyang16 阅读(134) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ double x,y; printf("Enter x(x>=0):\n"); scanf("%lf",&x); if(xint main(void){ double x,y; printf("Enter x(x>=0):\n"); scanf("%lf",&x); if(x<=15){ y=4*x/3; } else{ y=2.5*x-10.5; } printf("y=f(%f)=%.2f\n",x,y); r 阅读全文
posted @ 2013-10-02 20:23 zhaoyang16 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int celsius,fahr; fahr=100; celsius=5*(fahr-32)/9; printf("fahr=%d,celsius=%d\n",fahr,celsius); return 0;} 阅读全文
posted @ 2013-10-02 20:21 zhaoyang16 阅读(148) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ printf("Programming is fun.\n"); printf("And programming in C is even more fun!\n"); return 0;} 阅读全文
posted @ 2013-10-02 20:20 zhaoyang16 阅读(83) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ printf("Hello World!\n"); return 0;} 阅读全文
posted @ 2013-10-02 20:19 zhaoyang16 阅读(86) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int i,sum=0; for(i=1;i<=100;i++) if(i%2==0) sum=sum+i; printf("%d",sum); 阅读全文
posted @ 2013-10-02 20:04 zhaoyang16 阅读(103) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int n; int factorial(int n); scanf("%d",&n); printf("%d\n",factorial(n)); return 0;}int factorial(int n){ int i,fact=1; for(i=1;i<=n;i++) fact=fact*i; return fact;} 阅读全文
posted @ 2013-10-02 19:58 zhaoyang16 阅读(110) 评论(0) 推荐(0) 编辑