佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 986|回复: 1

高手请帮忙以下。。

[复制链接]
发表于 16-3-2009 08:40 PM | 显示全部楼层 |阅读模式
# include <iostream.h>
void main ()
{
int code ;
   char again ;
cout<< "Welcome to the APEX UNIVERSITY USM.\n\n";
   cout<<"\t\t*    *   *******   **     **"<<endl
       <<"\t\t*    *   *         * *   * *"<<endl
      <<"\t\t*    *   *         *  * *  *"<<endl
       <<"\t\t*    *   *******   *   *   *"<<endl
       <<"\t\t*    *         *   *       *"<<endl
       <<"\t\t*    *        *   *       *"<<endl
       <<"\t\t******   *******   *       *"<<endl<<endl ;
cout<< "Please register your course \n"
   << "For the Year 2009/2010 Semester 1\n"
     << "Here are the course available .\n\n " ;
   cout<< " Code\t\tCourse Name\n " ;
cout<< "-----------------------------\n" ;
cout<< "  1\t\tMaterial\n"
      << "  2\t\tMathematics\n"
      << "  3\t\tStatics\n"
      << "  4\t\tFluid Mechanic\n"
      << "  5\t\tFluid Dynamic\n"
      << "  6\t\tJapanese\n"
      << "  7\t\tEngineering Drawing\n\n"  ;
do
{
cout<< "Please select the course you wan to register  \n"
     << "by entering their code : " ;
   cin >> code ;
   while (code <1 || code >7)
   {
   cout<<"\nError !An invalid code was enter . \n" ;
   cout<<"Please enter code as written in above :"  ;
   cin>> code ;
   }
   cout<< "\nDo you still want to register for other courses ? (Y/N) " ;
   cin >> again ;
   }while(again== 'Y' || again == 'y');
cout << "\nHere are the course you register.\n" ;
cout << "\nCourse\t\tCourse Name\n" ;
cout << "-----------------------\n"   ;
}




我要如何把那些人输入的code 在我的新的cout 。
ie :
但他们输入 1 , 2 , and 3 , 我要怎样写喔??

请帮忙我噢。。
谢谢。。

[ 本帖最后由 guofeng 于 16-3-2009 10:28 PM 编辑 ]
回复

使用道具 举报


ADVERTISEMENT

发表于 16-3-2009 10:38 PM | 显示全部楼层
switch(code)
{
case 1:
{..................}
break;
.
.
.
case 7:
{.....}
break;

default:
{....}
或者用if...else if
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 15-12-2025 07:47 AM , Processed in 0.101375 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表