现在的位置: 首页 > 综合 > 正文

工大机试第三题 韩老师版

2014年01月10日 ⁄ 综合 ⁄ 共 684字 ⁄ 字号 评论关闭

3
某大桥按不同型号征收车辆过桥费:自行车免费,摩托车2元,小汽车5元,大客车与货车8元,货柜车12元。编写一个程序,按车辆的不同型号计算通过该大桥应征的过桥费。(提示:可以用整数对不同型号的车辆进行编码)

 #include

using namespace std;

int main()

{

      
cout<<"A replace bicycle
:"<<endl;

      
cout<<"B replace
motorcycle:"<<endl;

      
cout<<"C replace
car:"<<endl;

      
cout<<"D replace
bus:"<<endl;

      
cout<<"E replace
container"<<endl;

      
cout<<"enter a
char(A-E):"<<endl;

      
char a;

      
cin>>a;

      
switch(a)

      
{

      
case 'A': cout<<"should give 0
yuan."<<endl;break;

      
case 'B': cout<<"should give 2
yuan."<<endl;break;

      
case 'C': cout<<"should give 5
yuan."<<endl;break;

      
case 'D': cout<<"should give 8
yuan."<<endl;break;

      
case 'E': cout<<"should give 12
yuan."<<endl;break;

      
}

      
return 0;

}

 

 

抱歉!评论已关闭.