|
查看: 986|回复: 1
|
高手请帮忙以下。。
[复制链接]
|
|
|
# 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 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 16-3-2009 10:38 PM
|
显示全部楼层
switch(code)
{
case 1:
{..................}
break;
.
.
.
case 7:
{.....}
break;
default:
{....}
或者用if...else if |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|