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

类别:编程语言 点击:0 评论:0 推荐:

驱动菜单的雏形
#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;
}

本文地址:http://com.8s8s.com/it/it27502.htm