死了都看不懂的运行错误??
/*求S=2+2*2+2*2*2+....+n个2的值大家看下我的算法对不?*/
#include<stdio.h>
#include<math.h>
int main()
{int i,sum,n;
printf("input n:");
scanf("%d",&n);
if(n==1)
{sum=2;
printf("%d",sum);
}
else
{sum=2;
for(i=2;i<=n;i++)
sum=sum+pow(2,i);
prinf("%d",sum);
}
return ;
}
gcc suan.c
/tmp/ccSkQxWa.o(.text+0x86): In function `main':
: undefined reference to `pow'
/tmp/ccSkQxWa.o(.text+0xb9): In function `main':
: undefined reference to `prinf'
collect2: ld returned 1 exit status