CSDN博客

img lbsjs

驱动菜单的雏形6/2/04 9:58AM

发表于2004/9/13 16:24:00  927人阅读

驱动菜单的雏形
#include <iostream>
#include <ctype.h>

using namespace std;

int main()
{
  char r;
  cout << "please enter one of the following choices:/n";
  cout << "c) carnirore" << "  " << "  " << "p) pianist/n";
  cout << "t) tree" << " " << "        " << "g) game/n";
  cout << "please enter a c,p,t,or g:";

while(cin >> r)
  {
   r = tolower(r);
   if(r == 'c'|| r == 'p' || r == 't' || r == 'g')
    
    {switch (r)
      {
          case 'c': cout <<"a maple is a carnirore/n";
                            cout << "please enter a c,p,t,or g:";
                                    break;
          case 'p': cout <<"a maple is a pianist/n";
                    cout << "please enter a c,p,t,or g:";
                                    break;
          case 't': cout <<"a maple is a tree/n";
                    cout << "please enter a c,p,t,or g:";
                    
                                    break;
          case 'g': cout <<"a maple is a game/n";
                    cout << "please enter a c,p,t,or g:";
                                    break;
      }
     }
    else
      cout << "please enter a c,p,t,or g:";
       
     
    
  }
 
  return 0;
}

0 0

相关博文

我的热门文章

img
取 消
img