2021-10-05

#include
#include
using namespace std;
void showmenu() {
    cout << " Please enter one of the following choices :" << endl;
    cout << "c) carnivore" << "       " << "p)pianist" << endl;
    cout << "t) tree     " << "       " << "g)game" << endl;

}
int main()
{
    showmenu();
    while(true)
    {
        char score ;
        cout << "请给电影打分" << endl;
        cin.get(score);
        cin.get();//删除空白字符

        switch (score)
        {
        case 'a':
        case 'g':
            cout << "经典" << endl;
            break;
        default:
            cout << "烂片" << endl;
            break;
        }
    }
    system("pause");

    return 0;
}

要加上一行 cin.get();//删除空白字符  免得出现问题

你可能感兴趣的:(c++)