2013年10月8日
摘要: #includeint main(void){ int i,n,m; char s[10]; printf("Enter a string:"); i=0; while((s[i]=getchar( ))!='\n') i++; s[i]='\0'; for(n=0,m=i-1;n=m) printf("It is a plalindrome\n"); else printf("It is not plalindrome\n"); return 0;} 阅读全文
posted @ 2013-10-08 06:52 yy99 阅读(165) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,number; char str[10]; printf("Enter a string:"); i=0; while((str[i]=getchar( ))!='\n') i++; str[i]='\0'; number=0; for(i=0;str[i]!='\0';i++) if(str[i]>='0'&& str[i]<='9') number=number*10+str[i]-'0' 阅读全文
posted @ 2013-10-08 06:51 yy99 阅读(126) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,j,n,temp; int a[6][6]; printf("Enter n:"); scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<n;j++) a[i][j]=i*n+j+1; for(i=0;i<n;i++) for(j=0;j<n;j++) if(i<=j){ temp=a[i][j]; a[i][j]=a[j][i]; ... 阅读全文
posted @ 2013-10-08 06:50 yy99 阅读(162) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,j; int a[3][2]; for(i=0;i<3;i++) for(j=0;j<2;j++) a[i][j]=i+j; for(i=0;i<3;i++){ for(j=0;j<2;j++) printf("%4d",a[i][j]); printf("\n"); }return 0;} 阅读全文
posted @ 2013-10-08 06:50 yy99 阅读(130) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,k; char str1[80],str2[80]; long number; printf("Enter a string:"); i=0; while((str1[i]=getchar( ))!='\n') i++; str1[i]='\0'; k=0; for(i=0;str1[i]!='\0';i++) if(str1[i]>='0'&&str1[i]='a'&&str1[i]='A 阅读全文
posted @ 2013-10-08 06:49 yy99 阅读(122) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,number; char str[10]; printf("Enter a string:"); i=0; while((str[i]=getchar( ))!='\n') i++; str[i]='\0'; number=0; for(i=0;str[i]!='\0';i++) if(str[i]>='0'&& str[i]<='9') number=number*10+str[i]-'0' 阅读全文
posted @ 2013-10-08 06:49 yy99 阅读(166) 评论(0) 推荐(0)
摘要: #includeint main(void){ int col,i,j,row; int a[3][2]; printf("Enter 6intergers:\n"); for(i=0;ia[row][col]){ row=i; col=j; } printf("max=a[%d][%d]=%d\n",row,col,a[row][col]); return 0;} 阅读全文
posted @ 2013-10-08 06:46 yy99 阅读(148) 评论(0) 推荐(0)
摘要: #includeint main(void){ int a[10]={1,2,3,4,5,6,7,8,9,10}; int low,high,mid,n=10,x; printf("Enter x:"); scanf("%d",&x); low=0;high=n-1; while(low<=high) { mid=(low+high)/2; if(x==a[mid]) break; else if(x<a[mid]) high=mid-1; else ... 阅读全文
posted @ 2013-10-08 06:44 yy99 阅读(157) 评论(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 06:44 yy99 阅读(116) 评论(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 06:43 yy99 阅读(112) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,flag,x; int a[5]; printf("Enter 5 integers:"); for(i=0;i<5;i++) scanf("%d",&a[i]); printf("Enter x:"); scanf("%d",&x); flag=0; for(i=0;i<5;i++) if(a[i]==x){ printf("Index is %d\n",i); flag=1; break; ... 阅读全文
posted @ 2013-10-08 06:42 yy99 阅读(115) 评论(0) 推荐(0)
摘要: #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 06:42 yy99 阅读(99) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,index,n; int a[10]; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n); for(i=0;i<n;i++) scanf("%d",&a[i]); index=0; for(i=1;i<n;i++) if(a[i]<a[index]) index=i; printf("min is %d\tsub is %d\n& 阅读全文
posted @ 2013-10-08 06:42 yy99 阅读(160) 评论(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",3<=x<=5); return 0; } 阅读全文
posted @ 2013-10-08 06:42 yy99 阅读(119) 评论(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 06:42 yy99 阅读(109) 评论(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 06:42 yy99 阅读(167) 评论(0) 推荐(0)
摘要: #includefloat cash;int main(void){ int choice; float value; void income(float number),expend(float number); cash=0; printf("Enter operate choice(0--end,1--income,2--expend):"); scanf("%d",&choice); while(choice!=0){ if(choice==1||choice==2){ printf("Enter cash ... 阅读全文
posted @ 2013-10-08 06:41 yy99 阅读(150) 评论(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); print 阅读全文
posted @ 2013-10-08 06:41 yy99 阅读(108) 评论(0) 推荐(0)
摘要: #includeint main(void){ int i,index,k,n,temp; int a[10]; printf("Enter n:"); scanf("%d",&n); printf("Enter %d integers:",n); for(i=0;i<n;i++) scanf("%d",&a[i]); for(k=0;k<n-1;k++){ index=k; for(i=k+1;i<n;i++) if(a[i]<a[index]) index=i; temp 阅读全文
posted @ 2013-10-08 06:41 yy99 阅读(115) 评论(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 06:39 yy99 阅读(142) 评论(0) 推荐(0)
摘要: #includefloat result_real,result_imag;int main(void){ float imag1,imag2,real1,real2; void complex_prod(float real1,float image2,float real2,float imag2); void complex_add(float real1,float image2,float real2,float imag2); printf("Enter 1st complex number number(real and imaginary):"); ... 阅读全文
posted @ 2013-10-08 06:33 yy99 阅读(180) 评论(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 06:33 yy99 阅读(129) 评论(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==1)return 0;... 阅读全文
posted @ 2013-10-08 06:32 yy99 阅读(147) 评论(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 06:32 yy99 阅读(145) 评论(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 06:30 yy99 阅读(310) 评论(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 06:30 yy99 阅读(114) 评论(0) 推荐(0)
摘要: #includeint 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,women,child); } return 0;} 阅读全文
posted @ 2013-10-08 06:29 yy99 阅读(121) 评论(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 06:20 yy99 阅读(150) 评论(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 06:20 yy99 阅读(95) 评论(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 06:19 yy99 阅读(160) 评论(0) 推荐(0)
摘要: #includeint main(void){ int mark,max; printf("Enter marks:"); scanf("%d",&mark); max=mark; scanf("%d",&mark); max=mark; while(mark>=0){ if(max<mark) max=mark; scanf("%d",&mark); }; printf("Max=%d\n",max); return 0;} 阅读全文
posted @ 2013-10-08 06:17 yy99 阅读(156) 评论(0) 推荐(0)