可以输入任意数的任意次方 不会有溢出#include
#include
#define x 1000
int main(int argc, char *argv[])
{
char a[10];
long b[x];
long m,pown,n,i,j,k,c,flag,len;
while(scanf("%s%ld",a,&pown)!=EOF)
{
memset(b,0,sizeof(b));
len=strlen(a);
m=j=0;c=1;flag=1;n=0;
for(i=len-1;i>=0;i--)
{
if(a[i]=='.')
{flag=0;continue;}
m+=(a[i]-'0')*c;
c*=10;
if(flag)
n++;
}
if(m==0)
{printf("0\n");continue;}
if(pown==0) {printf("1\n");continue;} j=0;
for(i=len-1;i>=0;i--)
{
if(a[i]=='.') continue;
b[j++]=a[i]-'0';
}
if(flag==0){
n*=pown;c=0;
for(i=1;i
for(j=0;j
b[j]=b[j]*m+c;
c=b[j]/10;
b[j]%=10;
}
}
for(k=x-1;k>=0;k--)
if(b[k]) break;
for(c=0;c
n--;
if(n>k) k=n;
for(i=k;i>=c;i--)
{
if(i==n)
printf(".");
printf("%ld",b[i]);
}
printf("\n");
}
else
{
c=0;
for(i=1;i
for(j=0;j
b[j]=b[j]*m+c;
c=b[j]/10;
b[j]%=10;
}
}
for(k=x-1;k>=0;k--)
if(b[k]) break;
for(i=k;i>=0;i--)
printf("%ld",b[i]);
printf("\n");
}
}
return 0;
}
#include
double p(double x,int n)
{
int i;
double s=1;
for(i=1;i<=n;i++)
s*=x;
return s;
}
void main()
{
int n;
printf("输入N:");
scanf("%d",&n);
printf("%lf\n",p(3.2,n));
}
#include
void main()
{
int n;
scanf("%d",&n);
double fun(int n);
printf("%lf",fun(n));
}
double fun(int n)
{
int i;
double t=1;
for(i=1;i<=n;i++)
t*=3.2;
return t;
}
#include
scanf("%d",&n);
printf("%f",fun(n));
}
#include