C语言实现x的n次方
#include <stdio.h> // codeblock编辑和编译的#define uint8_t unsigned char
#define uint32_t unsigned int
#define POWER 16// 求x的n次方,返回x的n次方的值
uint32_t Power(uint8_t x, uint8_t n)
{uint8_t i;uint32_t val = 1;for(i = 0; i <= n; ++i){printf("%d^%d\t%d\n", x, i, val);val = x * val;}return val / x;
}int main(void)
{uint32_t sum;sum = Power(3, 16); // 3,16随便换,0~255printf("---%d---\n", sum);return 0;
}