#include <stdio.h>
#include <math.h>
void main()
{
?? ?long i,n,temp;
?? ?printf("请输入n\n");
?? ?scanf("%d",&n);
?? ?for ( i = 1 ; i <= n ; i++ )
?? ?{
?? ??? ?temp = pow(i,2);
?? ??? ?printf("%d的平方 = %d\n",i,temp);
?? ??? ?temp = pow(i,3);
?? ??? ?printf("%d的立方 = %d\n",i,temp);
?? ?}
}
?
总结:加了个#include <stdio.h> 的头文件,使用了pow(x,y)函数。
33734493