C++ primer plus第六版课后编程练习答案:6.3

#define  _CRT_SECURE_NO_WARNINGS 
#include 
#include
#include
using namespace std;

int main()
{
    char ch;

    cout << "Please enter one of the following choices:\n";
    cout << "c) carnivore\t\tp) painist\nt) tree\t\t\tg) game\n";
    ch=cin.get();
    while ((ch != 'c') &&(ch != 'p') && (ch != 't') && (ch != 'g'))
    {
        cout << "Please enter a c,p,t, or g: ";
        while (cin.get() != '\n')
            continue;
        ch = cin.get();
    }
    switch (ch)
    {
    case'c':cout << "A tiger is a carnivore.\n"; break;
    case'p':cout << "Langlang is a great pianist.\n"; break;
    case't':cout << "A maple is a tree.\n"; break;
    case'g':cout << "Narotu--the ninja storm 4 will public in 2015.\n"; break;
    default:
        break;
    }
    return 0;
}

你可能感兴趣的:(C++,primer,plus第六版课后编程练习)