2017年9月16日 星期六

[C_MM07-易] 計算平方值與立方值(C++)

因為用到pow()所以加上#include <math.h> 

  1. #include <iostream>  
  2. #include<iomanip>  
  3. #include <math.h>  
  4. using namespace std;  
  5.   
  6. int main() {  
  7.     int num;  
  8.     cin >> num;  
  9.     int square, cube;  
  10.     square = pow(num,2);  
  11.     cube = pow(num,3);  
  12.     cout << num << " " << square << " " << cube << endl;  
  13.     return 0;  
  14. }  

沒有留言:

張貼留言