摘要: #includeint main(void){ int i; int fib[10]={1,1}; for(i=2;i<10;i++) fib[i]=fib[i-1]+fib[i-2]; for(i=0;i<10;i++){ printf("%6d",fib[i]); if((i+1)%5==0) printf("\n"); } return 0;} 阅读全文
posted @ 2013-10-08 17:17 liruijia 阅读(127) 评论(0) 推荐(0)
摘要: #includeint main(void){ int count[9]; int i,response; for(i=1;i8) printf("this is a bad response:%d\n",response); else count[response]++; } printf("result:\n"); for(i=1;i<=8;i++) printf("%4d%4d\n",i,count[i]); return 0;} 阅读全文
posted @ 2013-10-08 17:16 liruijia 阅读(195) 评论(0) 推荐(0)
摘要: #includeint main(void){ char ch='w'; int a=2,b=0,c=0; float x=3.0; printf("%d",a&&b); printf("%d",a‖(b&&c)); printf("%d",!a&&b); printf("%d",a‖(3+10)&&2); printf("%d",!(x==2)); printf("%d",!x==2); pri 阅读全文
posted @ 2013-10-08 17:15 liruijia 阅读(203) 评论(0) 推荐(0)
摘要: #includeint main(void){ char ch; printf("input characters:"); ch=getchar(); while(ch!='\n'){ if(ch>='A'&&ch='a'&&ch<='z') ch=ch-'a'+'A'; putchar(ch); ch=getchar(); } return 0;} 阅读全文
posted @ 2013-10-08 17:14 liruijia 阅读(134) 评论(0) 推荐(0)
摘要: #includeint main(void){ char ch='w'; int a=2,b=3,c=1,d,x=10; printf("%d",a>b==c); printf("%d",d=a>b); printf("%d",ch>'a'+1); printf("%d",d=a+b>c); printf("%d",b-1==a!=c); printf("%d\n",3<=x<=5); return 0;} 阅读全文
posted @ 2013-10-08 17:13 liruijia 阅读(121) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i; char ch_lower,ch_upper; for(i=1;i='a'&&ch_lower%c->%d\n",ch_lower,ch_upper,ch_upper%10); } return 0;} 阅读全文
posted @ 2013-10-08 17:12 liruijia 阅读(114) 评论(0) 推荐(0)
摘要: #includedouble fact_s(int n);int main(void){ int i,n; printf("Input n:"); scanf("%d",&n); for(i=1;i<=n;i++) printf("%3d!=%.0f\n",i,fact_s(i)); return 0;}double fact_s(int n){ static double f=1; f=f*n; return(f);} 阅读全文
posted @ 2013-10-08 17:11 liruijia 阅读(114) 评论(0) 推荐(0)
摘要: #includeint x;int f();int main(void){ int a=1; x=a; a=f(); { int b=2; b=a+b; x=x+b; } printf("%d%d",a,x); return 0;}int f(){ int x=4; return x;} 阅读全文
posted @ 2013-10-08 17:10 liruijia 阅读(126) 评论(0) 推荐(0)
摘要: #includefloat result_real,result_imag;int main(void){ float imag1,imag2,real1,real2; void complex_prod(float real1,float imag1,float real2,float imag2); void complex_add(float real1,float imag1,float real2,float imag2); printf("Enter 1st complex number(real and imaginary):"); scanf("% 阅读全文
posted @ 2013-10-08 17:07 liruijia 阅读(144) 评论(0) 推荐(0)
摘要: #includeint x;int f();int main(void){ int a=1; x=a; a=f(); { int b=2; b=a+b; x=x+b; } printf("%d%d",a,x); return 0;}int f(){ int x=4; return x;} 阅读全文
posted @ 2013-10-08 17:06 liruijia 阅读(104) 评论(0) 推荐(0)
摘要: #includeint main(void){ void pyramid(int n); pyramid(5); return 0;}void pyramid(int n){ int i,j; for(i=1;i<=n;i++){ for(j=1;j<=n-i;j++) printf(" "); for(j=1;j<=i;j++) printf("%d",i); putchar('\n');}} 阅读全文
posted @ 2013-10-08 17:03 liruijia 阅读(134) 评论(0) 推荐(0)
摘要: #include#includeint main(void){ int count,m; int prime(int m); count=0; for(m=2;m<=100;m++){ if(prime(m)!=0){ printf("%6d",m); count++; if(count%10==0) printf("\n"); } } printf("\n");} int prime(int m){ int i,n; if(m=... 阅读全文
posted @ 2013-10-08 17:02 liruijia 阅读(112) 评论(0) 推荐(0)
摘要: #include#includeint main(void){ double e,pi; double funpi(double e); printf("Enter e:"); scanf("%lf",&e); pi=funpi(e); printf("pi=%f\n",pi); return 0;}double funpi(double e){ int denominator,flag; double item,sum; flag=1; denominator=1; item=1.0; sum=0; whil... 阅读全文
posted @ 2013-10-08 16:56 liruijia 阅读(164) 评论(0) 推荐(0)
摘要: #includeint main(void){ double height,radius,volume; double cylinder(double r,double h); printf("Enter radius and height:"); scanf("%lf%lf",&radius,&height); volume=cylinder(radius,height); printf("Volume=%.3f\n",volume); return 0;}double cylinder(double r,doubl 阅读全文
posted @ 2013-10-08 16:55 liruijia 阅读(161) 评论(0) 推荐(0)
摘要: #includeint main(void){ int child,men,women; for(men=0;men<=45;men++) for(women=0;women<=45;women++) for(child=0;child<=45;child++) if(men+women+child==45&&men*3+women*2+child*0.5==45) printf("men=%d,women=%d,child=%d\n",men,women,child); ... 阅读全文
posted @ 2013-10-08 16:53 liruijia 阅读(94) 评论(0) 推荐(0)
摘要: #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;} 阅读全文
posted @ 2013-10-08 16:52 liruijia 阅读(97) 评论(0) 推荐(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;} 阅读全文
posted @ 2013-10-08 16:51 liruijia 阅读(107) 评论(0) 推荐(0)
摘要: #includeint main(void){ int x; printf("Enter x:"); scanf("%d",&x); while(x!=0){ printf("%d",x%10); x=x/10; } return 0;} 阅读全文
posted @ 2013-10-08 16:50 liruijia 阅读(102) 评论(0) 推荐(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); r 阅读全文
posted @ 2013-10-08 16:47 liruijia 阅读(99) 评论(0) 推荐(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;} 阅读全文
posted @ 2013-10-08 16:46 liruijia 阅读(95) 评论(0) 推荐(0)
摘要: #includeint main(void){ int mynumber=38; int count=0,yournumber; for(count=1;countmynumber) printf("Sorry!you number is bigger than my number!\n"); else printf("Sorry!you number is smaller than my number!\n"); } printf("Game is over!\n"); re... 阅读全文
posted @ 2013-10-08 16:45 liruijia 阅读(117) 评论(0) 推荐(0)
摘要: #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;} 阅读全文
posted @ 2013-10-08 16:45 liruijia 阅读(162) 评论(0) 推荐(0)
摘要: #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;} 阅读全文
posted @ 2013-10-08 16:40 liruijia 阅读(80) 评论(0) 推荐(0)
摘要: #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;} 阅读全文
posted @ 2013-10-08 16:37 liruijia 阅读(115) 评论(0) 推荐(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("G... 阅读全文
posted @ 2013-10-08 16:08 liruijia 阅读(109) 评论(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-08 16:05 liruijia 阅读(107) 评论(0) 推荐(0)
摘要: #include#includeint main(void){ int denominator,flag; double item,pi; flag=1; denominator=1; item=1.0; pi=0; while(fabs(item)>=0.0001){ item=flag*1.0/denominator; pi=pi+item; flag=-flag; denominator=denominator+2; } pi=pi*4; printf("pi=%.4f\n",pi); r... 阅读全文
posted @ 2013-10-08 16:05 liruijia 阅读(147) 评论(0) 推荐(0)
摘要: #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 ... 阅读全文
posted @ 2013-10-08 16:02 liruijia 阅读(97) 评论(0) 推荐(0)
摘要: #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:") 阅读全文
posted @ 2013-10-08 16:01 liruijia 阅读(95) 评论(0) 推荐(0)
摘要: #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); b 阅读全文
posted @ 2013-10-08 16:01 liruijia 阅读(104) 评论(0) 推荐(0)
摘要: #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-08 15:58 liruijia 阅读(114) 评论(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-08 15:57 liruijia 阅读(170) 评论(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-08 15:57 liruijia 阅读(138) 评论(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-08 15:56 liruijia 阅读(128) 评论(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-08 15:53 liruijia 阅读(122) 评论(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-08 15:52 liruijia 阅读(121) 评论(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++){... 阅读全文
posted @ 2013-10-08 15:50 liruijia 阅读(73) 评论(0) 推荐(0)
摘要: #include#include int 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-08 12:53 liruijia 阅读(84) 评论(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-08 12:47 liruijia 阅读(130) 评论(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-08 12:46 liruijia 阅读(116) 评论(0) 推荐(0)
摘要: #includeint main(void){ int denominator,flag,i,n; double item,sum; printf("Enter n:"); scanf("%d",& flag=1; denominator=1; sum=0; for(i=1;i<=n;i++){ item=flag*1.0/denominator; sum=sum+item; flag=-flag; ... 阅读全文
posted @ 2013-10-08 12:43 liruijia 阅读(133) 评论(0) 推荐(0)
摘要: #include int 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;f... 阅读全文
posted @ 2013-10-08 10:36 liruijia 阅读(114) 评论(0) 推荐(0)
摘要: #include#include int main(void){ int money,year; double rate,sum; printf("Enter money:"); scanf("%d",&money); printf("Enter year:"); scanf("%d",&year); printf("Enter rate:"); scan... 阅读全文
posted @ 2013-10-08 10:34 liruijia 阅读(104) 评论(0) 推荐(0)
摘要: 2#includeint 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); return 0;} 阅读全文
posted @ 2013-10-08 10:29 liruijia 阅读(107) 评论(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-08 10:27 liruijia 阅读(133) 评论(0) 推荐(0)
摘要: #includeint main(viod){ printf(“Programming is fun.\n”); printf(“And programming in C is even more fun!\n”); return0;}2-22 阅读全文
posted @ 2013-10-08 10:24 liruijia 阅读(81) 评论(0) 推荐(0)
摘要: #include int main(void) { printf("Hello World!\n"); return0; } 阅读全文
posted @ 2013-10-08 10:15 liruijia 阅读(104) 评论(0) 推荐(0)