| ||||||||||
| 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 | |||||||||
为什么WAWAWAWAWAWA...?#include<iostream.h>
#include<memory.h>
#include<math.h>
void main()
{
char c[10];
int i=0,num=0,t=0;
int a[1000];
while(cin>>c>>t)
{
memset(a,0,sizeof(a));
num=0;
int j=0,dot=0,k=0;
for( j=0; c[j]!='\0'; j++ );
for( int jj=0; jj<j; jj++ ){ if(c[jj]=='.') dot=jj;}
dot=j-dot-1;
for( k=j-dot-1; k>0; k-- )
{
c[k]=c[k-1];
}
for( k=j-1; k>=1; k-- )
{
num+=(c[k]-'0')*pow(10,j-1-k);
}
int e=0,f=0;
for( k=0; k<j-1; k++ )
{
a[k]=c[j-1-k]-'0';
}
for( int l=0; l<t-1; l++ )
{
for( k=0; k<995; k++ )
{
f=num*a[k]+e;
a[k]=f%10;
e=f/10;
}
}
if(num==0){cout<<0<<endl;continue;}
if(t==0){cout<<1<<endl;continue;}
int length=0;int zeros=0;
for( k=999; a[k]==0; k--,length++ );
for( zeros=0; a[zeros]==0; zeros++ );
length=1000-length;
dot*=t;
for( k=length-1; k>=dot; k-- )
{
cout<<a[k];
}
if(dot!=zeros)cout<<'.';
for( k=dot-1; k>=zeros; k-- )
{
cout<<a[k];
}
cout<<endl;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator