C++入門經典-例3.12-使用if-else語句實現根據輸入的字符輸出字符串
阿新 • • 發佈:2017-09-13
++ names closed 應用 aps 字符串 fail hid logs
1:代碼如下:
// 3.12.cpp : 定義控制臺應用程序的入口點。 // #include "stdafx.h" #include <iostream> using namespace std; void main() { cout<<"輸入一個A-D範圍內的大寫字母作為成績評價"<<endl; char iInput; cin >> iInput; if(iInput == ‘A‘) { cout << "very good" <<endl; returnView Code; }else if(iInput == ‘B‘) { cout << "good" <<endl; return ; }else if(iInput == ‘C‘) { cout << "normal" <<endl; return ; }else if(iInput == ‘D‘) { cout << "failure" <<endl; return ; }else cout<< "input error" << endl; }
運行結果:
C++入門經典-例3.12-使用if-else語句實現根據輸入的字符輸出字符串