haha1235 |
|
||
2013年10月7日
摘要:
#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' 阅读全文
摘要:
#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]=' 阅读全文
摘要:
#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;} 阅读全文
摘要:
#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&q 阅读全文
摘要:
#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 阅读全文
摘要:
#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+l; for(i=0;i<n;i++) for(j=0;j<n;j++) if(i<=j){ temp=a[i][j]; a[i][j]=a[i][j]; ... 阅读全文
摘要:
#include int 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;} 阅读全文
摘要:
#include int 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; } if(f 阅读全文
摘要:
#include int 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; tem 阅读全文
摘要:
#include int 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 low=mid+1; } if(low<=high) printf(&quo 阅读全文
|
Copyright © 2024 haha1235
Powered by .NET 9.0 on Kubernetes |