3-39(fun 函数求x的n次幂)

来源:互联网 发布:mac安装卸载软件 编辑:程序博客网 时间:2024/06/09 19:24
/* Note:Your choice is C IDE */
#include "stdio.h"
int fun(int x , int n )
{
    int M,t;
    M=1;
    
    for(t=1;t<=n;t++)
    {
       M=M*x;
    }
    return M;
}
void main()
{
 int x,n,M;
 printf("Please input x and n:\n");
 scanf("%d%d",&x,&n);  
 M=fun(x,n);
 printf("%d的%d次幂是:%d\n",x,n,M); 

}



0 0
原创粉丝点击