功能:不用递归方式,编写函数fun,求任一整数m的n次

功能:不用递归方式,编写函数fun,求任一整数m的n次方。

#include<stdio.h>
void main()
{
    int m,n;
    long s;
    long fun(int,int);
    void TestFunc();
    printf("输入m和n的值:");
    scanf("%d%d",&m,&n);
    s=fun(m,n);
    printf("s=%ld\n",s);
    TestFunc();
}
long fun(int m,int n)
{
    long int x=1;
    int i;
    for(_____1_____)
        _____2_____
    _____3_____
}
void TestFunc()
{
    FILE *IN,*OUT;
    int n;
    int i[2];
    long o;
    IN=fopen("in.dat","r");
    if(IN==NULL)
    {
        printf("Read File Error");
    }
    OUT=fopen("out.dat","w");
    if(OUT==NULL)
    {
        printf("Write File Error");
    }
    for(n=0;n<2;n++)
    {
        fscanf(IN,"%d",&i[n]);
    }
    o=fun(i[0],i[1]);
    fprintf(OUT,"%ld\n",o);
    fclose(IN);
    fclose(OUT);
}
答案
第1空:i=1;i<=n;i++
第2空:x=x*m;
第3空:return x;

题目信息

题号:6807
题型:填空题
难度:普通