摘要:
#includeint main(void){ int child,men,women; for(men=0;menint main(void){ int child,men,women; for(men=0;men<=15;men++) for(women=0;women<=22;women++){ child=45-women-men; if(men*3+women*2+child*0.5==45) printf("men=%d,women=%d,child=%d\n",men,... 阅读全文
摘要:
#includeint main(void){ int i,x1,x2,x; x1=1; x2=1; printf("%6d%6d",x1,x2); for(i=1;i<=8;i++){ x=x1+x2; printf("%6d",x); x1=x2; x2=x; } printf("\n"); return 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;} 阅读全文
摘要:
#includeint main(void){ int x; printf("Enter x:"); scanf("%d",&x); while(x!=0){ printf("%d",x%10); x=x/10; } return 0;} 阅读全文
摘要:
#includeint 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;} 阅读全文
摘要:
#includeint main(void){ int i,mark,max,n; printf("Enter n:"); scanf("%d",&n); printf("Enter %d marks:",n); scanf("%d",&mark); max=mark; for(i=1;i<n;i++){ scanf("%d",&mark); if(max<mark) max=mark; } printf("Max=%d\n",max); 阅读全文
摘要:
#includedouble 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; for(i=1;i<=n;i++) result=result*i; return result;} 阅读全文
摘要:
#includeint main(void){ int i,m; printf("Enter a number:"); scanf("%d",&m); for(i=2;im/2&&m!=1) printf("%d is a prime number!\n",m); else printf("No!\n"); return 0;} 阅读全文
摘要:
#includeint main(void){ int mynumber=38; int count=0,yournumber; for(count=1;countmynumber) printf("Sorry!your number is bigger than my number!\n"); else printf("Sorry!your number is samller than my number!\n"); } printf("Game is over!\n"); ... 阅读全文
摘要:
#includeint main(void){ int count,number; count=0; printf("Enter a number:"); scanf("%d",&number); if(number<0)number=-number; do{ number=number/10; count++; }while(number!=0); printf("It contains %d digits.\n",count); 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){ ... 阅读全文
摘要:
#include#includeint main(void){ int denominator,flag; double item,pi; flag=1; denominator=1; item=1.0; pi=0; while(fabs(item)>=0.001){ item=flag*1.0/denominator; pi=pi+item; flag=-flag; denominator=denominator+2; } pi=pi*4; printf("pi=%.4f\n"... 阅读全文
摘要:
#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 阅读全文
摘要:
#includeint main(void){ int blank,digit,other; char ch; int i; blank=digit=other=0; printf("Enter 10 characters:"); for(i=1;i<=10;i++){ ch=getchar(); switch(ch){ case' ': case'\n': blank++; break; case'0':case'1':case'2':case... 阅读全文
摘要:
#includeint main(void){ double value1,value2; char op; printf("Type in an expression:"); scanf("%lf%c%lf",&value1,&op,&value2); switch(op){ case'+': printf("=%.2f\n",value1+value2); break; case'-': printf("=%.2f\n",value1-value2); . 阅读全文
摘要:
#includeint main(void){ int choice,i; double price; for(i=1;i<=5;i++){ printf("[1]Select crisps\n"); printf("[2]Select popcorn\n"); printf("[3]Select chocolate\n"); printf("[4]Select cola\n"); printf("[0]exit\n"); printf("Enter choice:") 阅读全文
摘要:
#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='0'&&ch<='9') digit++; else other++; } printf("letter=%d,digit=%d,other=%d\n",letter,digit,other); re 阅读全文
摘要:
#includeint main(void){ double valuel,value2; char op; printf("Type in an expression:"); scanf("%lf%c%lf",&valuel,&op,&value2); if(op=='+') printf("=%.2f\n",valuel+value2); else if(op=='-') printf("=%.2f\n",valuel-value2); else if(o 阅读全文
摘要:
# 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;} 阅读全文
摘要:
# 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++; } } ... 阅读全文