2013年10月5日
摘要: #includeint main(void){ int digit,letter,other; char ch; int i; digit=letter=other=0; printf("Enter 10 characters:"); for(i=1;i='a'&&ch='A'&&ch='0'&&ch<='9') digit++; else other++; } printf("letter=%d,digit=%d,other=%d\n" 阅读全文
posted @ 2013-10-05 23:49 yy99 阅读(133) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ double value1,value2; char op; printf("Type in an expression:"); scanf("%Lf%c%Lf",&value1,&op,&value2); if(op=='+') printf("=%.2f\n",value1+value2); else if(op=='-') printf("=%.2f\n",value1-value2); else if(o 阅读全文
posted @ 2013-10-05 20:02 yy99 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ double x,y; printf("Enter x:"); scanf("%Lf",&x); if(x<0){ y=0; } else if(x<=15){ y=4*x/3; } else{ y=2.5*x-10.5; } printf("f(%.2f)=%.2f\n",x,y); return 0;} 阅读全文
posted @ 2013-10-05 19:50 yy99 阅读(124) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int count,i,n; double grade,total; printf("Enter n:"); scanf("%d",&n); total=0; count=0; for(i=1;i<=n;i++){ printf("Enter grade#%d:",i); scanf("%lf",&grade); total=total+grade; if(grade<60){ count++; } } ... 阅读全文
posted @ 2013-10-05 19:38 yy99 阅读(126) 评论(0) 推荐(0) 编辑
摘要: #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-05 19:22 yy99 阅读(104) 评论(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("Sorry!your number is bigger than my number\n"); 阅读全文
posted @ 2013-10-05 19:05 yy99 阅读(150) 评论(1) 推荐(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++){... 阅读全文
posted @ 2013-10-05 18:33 yy99 阅读(123) 评论(1) 推荐(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-05 18:24 yy99 阅读(88) 评论(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-05 18:17 yy99 阅读(94) 评论(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(... 阅读全文
posted @ 2013-10-05 18:06 yy99 阅读(85) 评论(0) 推荐(0) 编辑
摘要: /*计算1+2+3+…+n*/#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 1 to %d is %d\n,",n,sum); return 0;} 阅读全文
posted @ 2013-10-05 17:51 yy99 阅读(74) 评论(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) 阅读全文
posted @ 2013-10-05 16:13 yy99 阅读(126) 评论(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("Entre rate:"); scanf("%lf",&rate); sum=money*pow(1+rate,year); printf 阅读全文
posted @ 2013-10-05 15:57 yy99 阅读(123) 评论(0) 推荐(0) 编辑