| ||||||||||
| 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 | |||||||||
头疼啊!这个是什么问题啊!我试了很多,但是,还是不知道 wrong的原因!#include<iostream.h>
#include<fstream.h>
//#decine length 6 95123
#define distingish 48
unsigned int result[151];//the result of computation
unsigned int temp_forStore[151];
void main()
{
// fstream cin("in.txt",ios::in||ios::out);
// fstream fout("out.txt",ios::out);
char input[7];//Rn where R
int real[7];// R is a real number ( 0.0 < R < 99.999 )
int point=0;
real[0]=6;
int n;//n is an integer such that 0 < n <= 25
cin>>input>>n;
int i,j,k;
/**/
for(i=0;i<6;i++)//initialize the point
{
if(input[i]=='.')
{
point=5-i;
real[0]--;
for(j=i+1;j<6;j++)
input[j-1]=input[j];
break;
}
}
for(i=real[0]-1;i>=0;i--)
{
if(input[i]=='0')
{
real[0]--;
point--;
}
else
break;
}
point*=n;
for(j=1;j<=real[0];j++)
{
real[j]=input[real[0]-j]-distingish;
result[j]=real[j];//initialize the temp_forStore[]
}
result[0]=real[0];//the number of digits in temp_forStore[] presently
unsigned int product;
for(i=1;i<n;i++)//times for producting the real[]
{
for(j=1;j<=real[0];j++)
{
for(k=1;k<=result[0];k++)
{
product=result[k]*real[j];
temp_forStore[k+j-1]+=product;
temp_forStore[k+j]+=temp_forStore[k+j-1]/10;
temp_forStore[k+j-1]%=10;
}//end temp_forStore[]
}//end real[]
for(k+=j;k>0;k--)
if(temp_forStore[k]!=0)
break;
temp_forStore[0]=k;
//copy the temp_forStore[] to result[]
for(;k>=0;k--)
{
result[k]=temp_forStore[k];
temp_forStore[k]=0;
}
}//end n
if(result[0]>point)
i=result[0];
else
i=point;
for(;i>0;i--)
{
if(i==point)
cout<<'.';
cout<<result[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