摘要: #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 00:42 傻子疯子捏子 阅读(156) 评论(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=1; temp 阅读全文
posted @ 2013-10-08 00:37 傻子疯子捏子 阅读(109) 评论(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 00:32 傻子疯子捏子 阅读(91) 评论(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 00:22 傻子疯子捏子 阅读(119) 评论(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 00:20 傻子疯子捏子 阅读(99) 评论(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 00:19 傻子疯子捏子 阅读(153) 评论(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 00:17 傻子疯子捏子 阅读(92) 评论(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 00:07 傻子疯子捏子 阅读(127) 评论(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 00:01 傻子疯子捏子 阅读(142) 评论(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-07 23:55 傻子疯子捏子 阅读(113) 评论(0) 推荐(0) 编辑