/*------------------------------------------------
【程序设计】
--------------------------------------------------
功能:编写函数fun,求任一整数m的n次方。
------------------------------------------------*/
#include <stdio.h>
void wwjt();
long fun(int m,int n)
{
/**********Program**********/
long int x=1;
int i;
for(i=1;i<=n;i++)
x = x*m;
return x;
/********** End **********/
}
main()
{
int m,n;
long s;
long fun(int,int);
printf("输入m和n的值:");
scanf("%d,%d",&m,&n);
s=fun(m,n);
printf("s=%ld\n",s);
wwjt();
}
void wwjt()
{
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);
}