1.求x的n次幂的函数
int what ( int x , int n)
{
int val;
int product;
product = 1;
val = x;
while (n > 0)
{
if (n%2 == 1)
product = product * val; /*如果是奇数次幂, x(val)要先乘上一次,; 偶数次幂,最后返回时才会到这里乘以1*/
val = val * val;
n = n / 2;
}
return product;
}