摘要:
#includeint main(void){ int i,n; double y; printf("Enter n:"); scanf("%d",&n); for(i=0;i<=n;i++){ if(n%2==0){ y=y-n/(2*n-1); } else{ y=y+n/(2*n-1); } } printf("%.2f",y); return 0;} 阅读全文
摘要:
#includedouble fact(int n);int main(void){ int i,n; double e; printf("Enter n:"); scanf("%d",&n); e=0; for(i=0;i<=n;i++){ e=e+fact(i); } printf("%.0f\n",e); return 0;}double fact(int n){int i;double result;result=1;for(i=1;i<=n;i++){ result=result*i;}return re 阅读全文
摘要:
#include#includeint main(void){ int i,n,y; double power; printf("Enter n:"); scanf("%d",&n); for(i=0;i<=n;i++){ power=pow(2,i); y=y+power; printf("%d",y); } return 0;} 阅读全文
摘要:
#includeint main(void){ int i, m,n; double y; printf("Enter m:"); scanf("%d",&m); printf("Enter n:"); scanf("%d",&n); for(i=m;i<=n;i++){ y=i*i+1/i; printf("%lf",y); } return 0;} 阅读全文
摘要:
#includeint main(void){ int count,num; double grade,total; num=0; total=0; count=0; printf("Enter grades:"); scanf("%lf",&grade); while(grade>=0){ total=total+grade; num++; if(grade<60) count++; scanf("%lf",&grade); } if(num!=0){ printf("Grade average 阅读全文
摘要:
#includeint main(void){ int x,y; printf("Enter x:"); scanf("%d",&x); if(x<=0){ y=-1; printf("%d",y); } else if(x=0){ y=0; printf("%d",y); } else{ y=1; printf("%d",y); } return 0;} 阅读全文
摘要:
#includeint main(void){int choice,i;double price;for(i=1;i<=5;i++){printf("[1]Select apples\n");printf("[2]Select pears\n");printf("[3]Select oranges\n");printf("[4]Select grapes\n");printf("[0]Select exit\n");printf("Enter choice:");sca 阅读全文
摘要:
#includeint main(void){char ch;printf("Enter the level(A B C D E):");ch=getchar();switch(ch){case'A':printf("The level is 90~100\n");break;case'B':printf("The level is 80~89\n");break;case'C':printf("The level is 70~79\n");break;case 阅读全文
摘要:
#includeint main(void){int year;printf("Enter The year:");scanf("%d",&year);while(year!=-1){if((year%4==0&&year%100!=0)||(year%400==0)){printf("The year is 闰年\n");printf("Enter The year:");scanf("%d",&year);}else{printf("The year 阅读全文
摘要:
#includeint main(void){int letter,digit,blank,other;char ch;int i;letter=digit=blank=other=0;printf("Enter 15 characters:");for(i=1;i='a'&&ch='A'&&ch='0'&&ch<='9') digit++; else if((ch='\n')||(ch=' ')) blank++; else 阅读全文
摘要:
#includeint main(void){ int i, n; double x,y,Y; printf("Enter n :"); scanf("%d",&n); printf("Enter x:"); scanf("%lf",&x); for(i=0;i<=n;i++){ y=x*x; Y=x*y; printf("%lf",Y); } return 0;} 阅读全文
摘要:
#includeint main(void){ int kwh; double free; printf("Enter kwh:"); scanf("%d",&kwh); if(kwh<=50){ free=0.53*kwh; printf("%.2f\n",free); } else{ free=0.53*50+0.58*(free-50); printf("%.2f\n",free); } return 0;} 阅读全文