1. 程式人生 > >C++入門經典-例3.12-使用if-else語句實現根據輸入的字符輸出字符串

C++入門經典-例3.12-使用if-else語句實現根據輸入的字符輸出字符串

++ 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;
        return
; }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; }
View Code

運行結果:

技術分享

C++入門經典-例3.12-使用if-else語句實現根據輸入的字符輸出字符串