标签:class put blog 算法 style ++ include pow scan
关于次方,是有函数pow()来专门计算的,但是今天学习了循环结构,有道题是让计算x的n次方,我就用for循环来实现一下。
#include <stdio.h>
int main() {
int x,n,p=1; #p为1,作为累积数
int i;
printf("Input number,power");
scanf("%d,%d",&x,&n);
for(i=0;i<n;i++){p*=x;}
printf("pow(%d,%d)=%d",x,n,p);
}
标签:class put blog 算法 style ++ include pow scan
原文地址:http://www.cnblogs.com/vilogy/p/6597488.html