【发布时间】:2021-05-30 14:28:43
【问题描述】:
我的 GCC 编译器给了我警告: power.c:在函数“main”中: power.c:9:36:警告:函数“power”的隐式声明 [-Wimplicit-function-declaration] 9 | printf("%d \t %d \t %d \n", i+1, power(2,i), power(-6,i)); |
而我已经明确声明了幂函数的隐式,我在下面的代码中给出了
#include <stdio.h>
int main(){
int i;
printf("%s \t %s \t %s \n", "Powers", "of 2", "of -6");
for (i = 0; i < 10; ++i)
printf("%d \t %d \t %d \n", i+1, power(2,i), power(-6,i));
return 0;
}
int power(int base, int n){
int i, p;
p = 1;
for (i=0; i <= n; ++i)
p = p * base;
return p;
}
【问题讨论】: