n的N次方,,怎么做??速度,,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/20 07:37:07
中文字在TC里显示不出啊,,,

#include <math.h>
#include <stdio.h>

main()
{
printf("%f",pow(x,y));
}

pow(x,y) x的y次方
函数返回值为float

#include<iostream.h>
void main()
{
int n,sum;
cout<<"输入n: "<<endl;
cin>>n;
if(n<=0)
cout<<"N值不合法"<<endl;
else
{
for(int i=0;i<n-1;i++)
{
sum=n;
sum=sum*n;
}
cout<<"n的n次方是: "<<sum<<endl;
}
}

更多 问题请加QQ群:4560047

加个头文件#include <math.h>然后pow ( n, N );就行了!!

#include <math.h>
#include <stdio.h>

main()
{
printf("%f",pow(x,y));
}

pow(x,y) x的y次方

换个编译器。