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 |
请教各位大牛,小弟实在不知该如何判断输入结束#include<iostream.h> #include<memory.h> int record[1000]; int count[1000]; int K; int keep; void counter(int array[1000],int dep,int counte) { int i; if(counte==count[keep]){ int sum=4*count[keep]; int pro=0; while(array[pro]==0){pro++;} if(sum==dep+1){ for(i=dep;i>=0;i--){ cout<<array[i]; } cout<<endl; } else if(sum>dep+1){ cout<<"."; for(i=1;i<=sum-dep-1;i++){ cout<<0; } for(i=dep;i>=pro;i--){ cout<<array[i]; } cout<<endl; } else{ if(sum<=pro){ for(i=dep;i>=sum;i--){ cout<<array[i]; } cout<<endl; } if(sum>pro){ for(i=dep;i>=sum;i--){ cout<<array[i]; } cout<<"."; for(i=sum-1;i>=pro;i--){ cout<<array[i]; } cout<<endl; } } } else{ int max,m; int j; int record2[1000]; memset(record2,0,sizeof(record2)); for(i=0;i<=K;i++){ m=i; for(j=0;j<=dep;j++){ record2[m]=record2[m]+(record[i]*array[j])%10; record2[m+1]=record2[m+1]+(record[i]*array[j])/10; m++; } } if(record2[m]!=0){max=m;} else max=m-1; for(i=0;i<=max;i++){ if(record2[i]>=10){ record2[i+1]=record2[i+1]+record2[i]/10; record2[i]=record2[i]%10; } } if(record2[max+1]!=0){max=max+1;} counter(record2,max,counte+1); } } void main() { double buttom[1000]; int total[1000]; cin>>buttom[0]>>count[0]; int i=0; while(){ cin>>buttom[i+1]>>count[i+1]; i++; } int k=i; for(i=0;i<=k;i++){ total[i]=buttom[i]*10000; int j=0; memset(record,0,sizeof(record)); while(total[i]>0){ record[j]=total[i]%10; total[i]=total[i]/10; j++; } K=j-1; keep=i; counter(record,K,1); } //cin>>i; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator