摘要:
#include int 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'3':case 阅读全文
摘要:
#include int main(void) { double valuel,value2; char op; printf("Type in an expression:"); scanf("%lf%c%lf",&value1,&op,&value2); switch(op){ case'+': printf("=%.2f\n",valuel+value2); break; case'-': printf("=%.2f\n",valuel-value2); 阅读全文
摘要:
#include intmain(void) { intchoice,i; doubleprice;for(i=1;i<=5;i++){ printf("[1]Selectcrisps\n"); printf("[2]Selectpopcorn\n"); printf("[3]Selectchocolate\n"); printf("[4]Selectcola\n"); printf("[0]exit\n");printf("Enterchoice:"); scanf( 阅读全文
摘要:
#include int 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" 阅读全文
摘要:
#include int 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( 阅读全文
摘要:
#include int 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\n",x,y);return 0; } 阅读全文
摘要:
#include int 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 grage#%d:",i); scanf("%lf",&grade); total=total+grade; if(grade<60){ count++; } } printf("Grad 阅读全文
摘要:
#include int 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; } 阅读全文
摘要:
#include double fact(int n); #include int 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 big 阅读全文
摘要:
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++){ product=product*i; } return pro 阅读全文