Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:c语言的源代码In Reply To:c语言的源代码 Posted by:1115267126 at 2016-03-04 17:42:40 > #include<stdio.h> > #include<string.h> > void rmpoint(char a[],int* c) > { > int i,j,p,c1; > c1=0; > char b[205]; > p=strlen(a); > for(i=0,j=0;i<p;i++) > { > if(a[i]=='.') > { > c1=p-1-i; > continue; > } > a[j]=a[i]; > j++; > } > *c=c1; > a[j]=0; > } > void chen(char a[],char b[]) > { > int c[410]={0}; > int i,j,sum,k,k1; > k=409; > k1=409; > for(i=strlen(a)-1;i>=0;i--) > { > for(j=strlen(b)-1;j>=0;j--,k--) > { > sum=(a[i]-'0')*(b[j]-'0')+c[k]; > c[k-1]=c[k-1]+sum/10; > c[k]=sum%10; > } > k=--k1; > } > > for(i=0;i<410;i++) > if(c[i]!=0) > break; > for(j=i,i=0;j<410;j++,i++) > b[i]=c[j]+'0'; > b[i]=0; > } > void addpoint(char a[],char b[],int p) > { > int i,j,p1,p2,j1,min; > p2=0; > p1=strlen(a); > if(p1>=p) > { > p=p1-p; > for(i=p1-1;i>=0;i--) > { > if(a[i]!='0') > break; > p2++; > } > if(p1-p2<p) > min=p; > else > min=p1-p2; > for(i=0,j=0;i<min;i++,j++) > { > if(p==i) > { > b[j]='.'; > i--; > p--; > continue; > } > b[j]=a[i]; > } > b[j]=0; > } > else > { > b[0]='.'; > p=p-p1; > for(i=p1-1,j1=0;p1>=0;i--) > { > if(a[i]!='0') > break; > j1++; > } > for(i=1,j=0;j<p;j++,i++) > b[i]='0'; > for(j=0;j<p1-j1;i++,j++) > b[i]=a[j]; > b[i]=0; > } > > } > int main() > { > char n1[7],n2[410],n3[410]; > int a,p,i; > while(scanf("%s %d",n1,&a)==2) > { > rmpoint(n1,&p); > strcpy(n2,n1); > for(i=0;i<a-1;i++) > { > chen(n1,n2); > } > p=p*a; > if(p!=0) > addpoint(n2,n3,p); > printf("%s\n",n3); > } > /*p=strlen(n3); > for(a=0;a<p;a++) > printf("%c",n3[a]); > }*/ > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator