| ||||||||||
| 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 | |||||||||
求HELP !#include <iostream>
#include <string>
//#include <fstream>
using namespace std;
int main(){
//ifstream cin("aaa.txt");
string s;
int n;
while(cin>>s>>n){
while(s.length() != 6) s = "0"+s;
//cout<<s<<" "<<n<<endl;
int i,j,k,tag=5;
for(i=0;i<6;i++)
if(s[i]=='.'){ tag=i; s.erase(i,1); break; }
if(i==6) s.erase(0,1);
string x(200,'0'),y,yy(200,'0');
for(i=0;i<=4;i++) x[195+i]=s[i];
for(i=1;i<n;i++){//相乘n次
y=yy;
for(k=4;k>=0;k--){//相乘5位
int carr=0,d,ii = 199 - (4-k);
for(j=199;j>=50;j--){//每一位相乘
d=(s[k]-'0')*(x[j]-'0')+carr+(y[ii]-'0');
carr=d/10;
y[ii--]=char(d%10 + '0');
}
y[ii]=carr+'0';
}
x=y;
}
y.insert(200-(5-tag)*n,1,'.');//添加小数点
while(y[0]=='0') y.erase(0,1); //去掉前导0
while(y[y.length()-1]=='0') y.erase(y.length()-1,1);//去掉后面0
if(y[y.length()-1]=='.') y.erase(y.length()-1,1);//去掉后面小数点.
cout<<y<<endl;
}
return 0;
}
为啥Runtime Error????
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator