摘要: #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-06 11:42 plusfancy 阅读(136) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int count,i; char str[80]; printf("Enter a string:"); i=0; while((str[i]=getchar())!='\n') i++; str[i]='\0'; count=0; for(i=0;str[i]!='\0';i++) if(str[i]='0') count++; printf("count=%d\n",count); return 0;} 阅读全文
posted @ 2013-10-06 11:40 plusfancy 阅读(80) 评论(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-06 11:26 plusfancy 阅读(83) 评论(0) 推荐(0) 编辑
摘要: #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 a plalindrome\n"); return 0;} 阅读全文
posted @ 2013-10-06 10:45 plusfancy 阅读(93) 评论(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]; ... 阅读全文
posted @ 2013-10-06 10:34 plusfancy 阅读(86) 评论(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-06 10:23 plusfancy 阅读(81) 评论(0) 推荐(0) 编辑
摘要: #includeint main(void){ int col,i,j,row; int a[3][2]; printf("Enter 6 integers:\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-06 09:35 plusfancy 阅读(86) 评论(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-06 08:51 plusfancy 阅读(95) 评论(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-06 08:24 plusfancy 阅读(69) 评论(0) 推荐(0) 编辑