// C5_6.cpp : Defines the entry point for the console application. // 指標與字串 #include "stdafx.h" #include using namespace std; int main(int argc, char* argv[]) { char* Pointer[] = { "陽明山國家公園", // 初始化指標陣列 "玉山國家公園", "太魯閣國家公園", "金門國家公園", "雪霸國家公園", "墾丁國家公園" }; char* Pp = "選取的是 : "; int Choice = 0; cout << endl << " 請選取一國家公園 !" << " 請選擇 1 至 6 數值 : "; cin >> Choice; cout << endl; if(Choice >= 1 && Choice <= 6) // 檢查輸入值 cout << Pp << Pointer[Choice-1]; // 輸出訊息 else cout << "輸入的值無效,請重新輸入。"; // 無效輸入 cout << endl; return 0; }