返回列表 發帖

pow() 函式 - 計算冪次與開根號

利用pow() 函式, 設計一個可以輕鬆計算冪次與開根號的計算機.

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x, y;
  8.     cout<<"請輸入底數: ";
  9.     cin>>x;
  10.     cout<<"請輸入指數: ";
  11.     cin>>y;
  12.     cout<<x<<"的"<<y<<"次方,值為"<<pow(x,y)<<endl;
  13.     system("pause");
  14.     return 0;   
  15. }
複製代碼
Su Wa

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double a,b;
  8.     cout<<"請輸入底數:";
  9.     cin>>a;
  10.     cout<<"請輸入指數:";
  11.     cin>>b;
  12.     cout<<a<<"的"<<b<<"次方,值為"<<pow(a,b)<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x,y;
  8.     cout<<"請輸入底數:";
  9.     cin>>x;
  10.     cout<<"請輸入指數";
  11.     cin>>y;
  12.     cout<<"底數為:"<<x<<"指數為:"<<y<<"的方程式為:"<<pow(x,y);
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼
Jian-wei Wang

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x, y;
  8.     cout<<"請輸入底數: ";
  9.     cin>>x;
  10.     cout<<"請輸入指數: ";
  11.     cin>>y;
  12.     cout<<x<<"的"<<y<<"次方,值為"<<pow(x,y)<<endl;
  13.     system("pause");
  14.     return 0;   
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x,y;
  8.     re:
  9.     cout<<"請輸入底數: ";
  10.     cin>>x;
  11.     cout<<"請輸入指數: ";
  12.     cin>>y;
  13.     cout<<x<<"的"<<y<<"次方,值為: "<<pow(x,y)<<endl;
  14.     goto re;
  15.     system("pause");
  16.     return 0;
  17.    
  18. }
複製代碼
Vincent

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.   re:
  8.   double x,y;
  9.   cout<<"請輸入底數:";
  10.   cin>>x;
  11.   cout<<"請輸入指數:";
  12.   cin>>y;
  13.   cout<<x<<"的"<<y<<"次方,值為"<<pow(x,y)<<endl;
  14.   goto re;
  15.   system("pause");
  16.   return 0  ;  
  17. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double a,b;
  8.     cout<<"請輸入底數:";
  9.     cin>>a;
  10.     cout<<"請輸入指數:";
  11.     cin>>b;
  12.     cout<<a<<"的"<<b<<"次方為"<<pow(a,b)<<endl<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x, y;
  8.     cout<<"請輸入底數: ";
  9.     cin>>x;
  10.     cout<<"請輸入指數: ";
  11.     cin>>y;
  12.     cout<<x<<"的"<<y<<"次方,值為"<<pow(x,y)<<endl;
  13.     system("pause");
  14.     return 0;   
  15. }
複製代碼
蔡少宇

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x, y;
  8.     cout<<"請輸入底數: ";
  9.     cin>>x;
  10.     cout<<"請輸入指數: ";
  11.     cin>>y;
  12.     cout<<x<<"的"<<y<<"次方,值為"<<pow(x,y)<<endl;
  13.     system("pause");
  14.     return 0;   
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     double x,y;
  8.     cout<<"請輸入底數: ";
  9.     cin>>x;
  10.     cout<<"請輸入指數: ";
  11.     cin>>y;
  12.     cout<<x<<"的"<<y<<"次方,值為"<<pow(x,y)<<endl;
  13.     system("pause");
  14.     return 0;
  15. }
複製代碼

TOP

  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<time.h>
  4. #include<math.h>
  5. using namespace std;
  6. int main()
  7. {
  8.         double x,y;
  9.         cout<<"請輸入底數:";
  10.         cin>>x;
  11.         cout<<"請輸入指數:";
  12.         cin>>y;
  13.         cout<<"x的y次方為"<<pow(x,y);
  14.         system("pause");
  15.         return 0;
  16. }
複製代碼

TOP

返回列表