4 回答

TA貢獻1017條經(jīng)驗 獲得超1032個贊
#include<stdio.h>
#include<math.h>
void main(){
???????? float x,y;
???????? float total=0;
???????? printf("x=");
???????? scanf("%f",&x);
???????? printf("y=");
???????? scanf("%f",&y);
???????? total=(float)pow(x,y);
????????printf("%.3f的%.3f次冪為:%.3f\n",x,y,total);
}

TA貢獻86條經(jīng)驗 獲得超114個贊
#include <math.h> 里面有個求冪的函數(shù), pow(x, n) 就是求得x的n次冪, 下面是代碼。有什么不會的歡迎隨時詢問。
#include<stdio.h>
#include<math.h>
int main(){
? ? ? ? double x,n;
? ? ? ? double sum = 0;
? ? ? ? printf("x=");
? ? ? ? scanf("%lf",&x);
? ? ? ? printf("n=");
? ? ? ? scanf("%lf",&n);
? ? ? ? sum=(double)pow(x,n);
? ? ? ? printf("%.3lf的%.3lf次冪為:%.3lf\n",x,n,sum);
? ? ? ? return 0;
}
- 4 回答
- 0 關(guān)注
- 1701 瀏覽
添加回答
舉報