20marks.....C语言问题

来源:百度知道 编辑:UC知道 时间:2024/06/09 15:31:18
how to do this question.
Write a program that computer X^N where x and N are positive integers. The program must inform the user that N must be positive if the user enters a negative value.

#include<stdio.h>
#include<math.h>
void main()
{
float X,N;
double S;
printf("please input X,N:");
scanf("%f,%f",&X,&N);
if(N<0)
{
printf("N must be positive!");
}
else
{
S=pow(X,N);
printf("result:%f\n",S);
}

}

写程序,计算机χ ^ n其中X和N的正整数。该提示必须告知用户, n必须是正的,如果用户输入一个负值。

就是计算幂。如果输入的是负数转换成整数,
这都不会??OMG。你不如去死好了。