// C3_2.cpp : Defines the entry point for the console application. // 巢狀的 if 敘述句 #include "stdafx.h" #include using namespace std; int main(int argc, char* argv[]) { char data = 0; // 設定初始值 int i = 0; start: if(i <= 3 ) // 外層 if 迴圈 { i = i + 1 ; cout << endl << "請輸入一字元 : "; // 提示輸入 cin >> data; // 讀取一字元 if(data >= 'A') // 測試大於等於 'A' if(data <= 'Z') // 測試小於等於 'Z' { cout << endl << " *** 輸入為大寫英文字母。" << endl; cout << " 輸入字母 : " << data << endl // __toascii 函式為字元轉為 ASCII 碼 << " ASCII code : " << __toascii(data) << endl; } if(data >= 'a') // 測試大於等於 'a' if(data <= 'z') // 測試小於等於 'z' { cout << endl << " *** 輸入為小寫英文字母。" << endl; cout << " 輸入字母 : " << data << endl << " ASCII code : " << __toascii(data) << endl; // return 0; } goto start; // 跳至 start 標纖 } return 0; }