| ||||||||||
| 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:用java的pow函数,一句话In Reply To:用java的pow函数,一句话 Posted by:superman2006 at 2007-08-11 15:05:55 #include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
char str[31];
int n,d;
scanf("%d%d",&n,&d);
while(n||d)
{
memset(str,'0',sizeof(str));
str[30]=0;
str[29]=n+'0';
// puts(str);
if(n==10)
{
printf("1");
int sum=0;
while(d--)
printf("0");
printf("\n");
scanf("%d%d",&n,&d);
continue;
}
else if(d==0)
{
cout<<"1\n";
scanf("%d%d",&n,&d);
continue;
}
while(d!=1)
{
int flag=0;
for(int i=29;i>=0;i--)
{
flag=n*(str[i]-'0')+flag;
str[i]=flag%10+'0';
flag=flag/10;
}
d--;
}
int k=0;
for(k=0;str[k]=='0';k++);
puts(str+k);
scanf("%d%d",&n,&d);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator