C++ 入門指南 4.01
練習 21.9 參考程式 - 練習標準程式庫的數學相關程式
// 引入標準程式庫中相關的輸入、輸出程式
#include <iostream>
// 引入標準程式庫中數學相關程式
#include <cmath>
// cout 為 std 中的輸出物件
using std::cout;
// endl 為 std 中的斷行符號
using std::endl;
int main(void) {
// 計算指數
cout << pow(2, 6) << endl;
cout << pow(2, 7) << endl;
cout << pow(2, 8) << endl;
cout << pow(2, 9) << endl;
cout << pow(2, 10) << endl;
// 最後回傳 0 給作業系統
return 0;
}
/* 《程式語言教學誌》的範例程式
http://kaiching.org/
檔名:exercise2009.cxx
編譯:g++ exercise2009.cxx
執行:./a.out
功能:C++入門指南單元二十的練習
作者:張凱慶 */
回到練習題目