1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include<iostream> using namespace std;
enum {red,orange,yellow,green,blue,violet,indigo};
int main(void) { int code; cout<<"Enter colot code(0~6):"; cin>>code;
while(code>=red && code<=indigo) { switch(code) { case red: cout<<"You choose red!"<<endl; break; case orange: cout<<"You choose orange!"<<endl; break; case yellow: cout<<"You choose yellow!"<<endl; break; case green: cout<<"You choose green!"<<endl; break; case blue: cout<<"You choose blue!"<<endl; break; case violet: cout<<"You choose violet!"<<endl; break; case indigo: cout<<"You choose indigo!"<<endl; break; default: cout<<"Impossible!"<<endl; break; } cout<<"Enter colot code(0~6):"; cin>>code; } cout<<"Bye!"<<endl; return 0; }
|