ex22.c
来自「Keil Cx51 V7.0书籍配套光盘中的全部源码」· C语言 代码 · 共 18 行
C
18 行
#include <stdio.h>
main() { /* 主函数体 */
int x, n, p, power(int x, int n);
printf("caculate X to the power of N\n please input X and N ? ");
scanf("%d%d",&x,&n);
p = power(x,n); /* 在此处调用函数 */
printf("%d to the power of %d = %d\n",x,n,p);
while(1);
}
int power(int x,int n) /* 被调用函数 */
int x, n;
{
int i, p = 1;
for( i=0; i<n; ++i ) p *= x;
return( p ); /* 带值返回到调用处 */
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?