返回列表 發帖

pow函式運用

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

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

TOP

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

TOP

#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
    double a,s;
   
    cout<<"數字"<<endl;
    cin>>a;
    cout<<"數字"<<endl;
    cin>>s;
   
    cout<<a<<"的"<<s<<"次方為"<<pow(a,s)<<endl;
    system("pause");
    return 0;
      
}

TOP

#include<iostream>
#include<cstdlib>  
#include<cmath>
using namespace std;
int main()
{
    double num,num1;
    cout<<"請輸入數字:";
    cin>>num;
    cout<<"請輸入數字:";
    cin>>num1;
    cout<<num<<"的"<<num1<<"次方:"<<pow(num,num1)<<endl;
   
    system("pause");
    return 0;
      
}

TOP

返回列表