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:搞了两天……………… Posted by:guowangguilai at 2008-04-16 19:57:29 > 有没有最bt的数据啊?我的怎么还wa啊?! > > > 高手给点建议? > > > > > #include<iostream.h> > #include<stdio.h> > #include<stdlib.h> > int main() > { > int n,i; > void display(char*,int); > //cin>>n; > n=1;//共有六祖数据; > > char**a=new char*[n]; > for(i=0;i<n;i++) > a[i]=new char[7]; > > int *b=new int[n]; > > for(i=0;i<n;i++) > scanf("%s %d",a[i],&b[i]); > > for(i=0;i<n;i++) > display(a[i],b[i]); > > return 0; > } > void display(char *a,int n) > { > int m,i,k=10,q,t=0,d=0,head,last,flag=0; > for(i=0;i<6;i++) > { > > if(a[i]!='.') > > t=t*10+a[i]-'0'; > > else k=i; > > }//是不是一定会有小数点? > > > > > long int*j=new long int[5*n]; > if(k==10) > {for(i=0;i<5*n;i++)j[i]=0; > > j[0]=1; > > for(m=0;m<n;m++) > > { > > q=0; > for(i=0;i<5*n;i++) > > {j[i]=j[i]*t+q;q=j[i]/10;j[i]=j[i]%10;} > > } > > > for(i=5*n-1;i>=0;i--) > if(j[i]!=0){flag=1;break;} > head=i; > > if(flag==0){cout<<'0'<<endl;return;} > > > > > {for(i=head;i>=0;i--) > printf("%ld",j[i]); > cout<<endl; > return;}} > > for(i=0;i<5*n;i++)j[i]=0; > > j[0]=1; > > for(m=0;m<n;m++) > > { > > q=0; > for(i=0;i<5*n;i++) > > {j[i]=j[i]*t+q;q=j[i]/10;j[i]=j[i]%10;} > > } > > > for(i=5*n-1;i>=0;i--) > if(j[i]!=0){flag=1;break;}; > head=i; > if(flag==0){cout<<'0'<<endl;return;} > > > > for(i=0;i<n*5;i++) > if(j[i]!=0)break; > last=i; > > if(last>=n*(5-k)) > {for(i=head;i>=n*(5-k);i--) > printf("%ld",j[i]); > cout<<endl; > return;} > for(i=head;i>=n*(5-k);i--)printf("%ld",j[i]); > printf("."); > for(i=n*5-n*k-1;i>=last;i--)printf("%ld",j[i]); > cout<<endl; > > > > } > > Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator