输出从3的零次方到3的n次方的值,可调用幂函数写了个开头~~#include <stdio.h>#include <math.h>int main(void)那个n的值是在运行时输入的~~~!!!!!最好是用printf~scanf~之类的
//==================C++语言版========================= #include <iostream> #include <cmath> using namespace std; int main() { const int n=10; for(int i=0;i<n+1;i++) { cout<<"3^"<<i<<"="<<pow(3.0,i*1.0)<<endl; } } //========================================================== //运行结果 3^0=1 3^1=3 3^2=9 3^3=27 3^4=81 3^5=243 3^6=729 3^7=2187 3^8=6561 3^9=19683 3^10=59049 /******************C语言版**********************/ #include <stdio.h> #include <math.h> main()/* 最好写成main,改成int main(void)也没有错 */ { const int n=10; int i; for(i=0;i<n+1;i++) { printf("3^%d=%-10.0f\n",i,pow(3.0,i*1.0)); } } /******************运行结果************************/ 3^0=1 3^1=3 3^2=9 3^3=27 3^4=81 3^5=243 3^6=729 3^7=2187 3^8=6561 3^9=19683 3^10=59049
//==================C++语言版=========================#include#includeusingnamespacestd;intmain(){constintn=10;for(inti=0;i评论00加载更多