永发信息网

这段C++程序哪里错了?newline in constants yntax error : missing ';' before identifier 'cin&apo

答案:2  悬赏:0  手机版
解决时间 2021-04-16 02:34

#include <iostream>
using namespace std;
void main()
{
int n,k,l;
int i=1,j=6;
int a[5]={0,0,0,0,0};
int b[5]={0,0,0,0,0};
loop0:cout<<"Please type 1 for First Class "<<endl;
cout<<"Please type 2 for Economy "<<endl;
cin>>n;
if (n==1){
loop1:if(i<=5){
cout<<"First Class. Your number is "<<i<<endl;
i=i+1;
}
else {
cout<<"First Class is full. Do you want Economy Seat? Please type 1 for YES,type 2 for NO<<endl;
cin>>k;
if(k==1){
if(j>10){cout<<"Sorry, Economy Seat is full too. Next flight leaves in 3 hours."<<endl;}
else {goto loop2;}
}
if(k==2){cout<<"Next flight leaves in 3 hours."<<endl;}
}

if(n==2){
loop2:if(j<=10){cout<<"Economy. Your number is "<<j<<endl;
j=j+1;}
else {
cout<<"Economy is full. Do you want First Class Seat? Please type 1 for YES, type 2 for NO<<endl;
cin>>l;
if(l==1){
if(k>5){cout<<"Sorry, Economy Seat is full too. Next flight leaves in 3 hours."<<endl;}
else {goto loop1;}
}
if(l==2){cout<<"Next flight leaves in 3 hours."<<endl;}
}
}
if(i<=4||j<=9)goto loop0;
}

编译后显示错误:
\VC++6.0\VisualC++6.0简体中文绿色版\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(18) : error C2001: newline in constant
D:\VC++6.0\VisualC++6.0简体中文绿色版\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(19) : error C2146: syntax error : missing ';' before identifier 'cin'
D:\VC++6.0\VisualC++6.0简体中文绿色版\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(31) : error C2001: newline in constant
D:\VC++6.0\VisualC++6.0简体中文绿色版\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(32) : error C2146: syntax error : missing ';' before identifier 'cin'
D:\VC++6.0\VisualC++6.0简体中文绿色版\Microsoft Visual Studio\Common\MSDev98\Bin\Cpp1.cpp(45) : fatal error C1004: unexpected end of file found

最佳答案
#include <iostream>
using namespace std;
main()
{
int n,k,l;
int i=1,j=6;
int a[5]={0,0,0,0,0};
int b[5]={0,0,0,0,0};
loop0:cout<<"Please type 1 for First Class "<<endl;
cout<<"Please type 2 for Economy "<<endl;
cin>>n;
if (n==1){
loop1:if(i<=5){
cout<<"First Class. Your number is "<<i<<endl;
i=i+1;
}
else {
cout<<"First Class is full. Do you want Economy Seat? Please type 1 for YES,type 2 for NO"<<endl;// 加双引号
cin>>k;
if(k==1){
if(j>10){cout<<"Sorry, Economy Seat is full too. Next flight leaves in 3 hours."<<endl;}
else {goto loop2;}
}
if(k==2){cout<<"Next flight leaves in 3 hours."<<endl;}
}

if(n==2){
loop2:if(j<=10){cout<<"Economy. Your number is "<<j<<endl;
j=j+1;}
else {
cout<<"Economy is full. Do you want First Class Seat? Please type 1 for YES, type 2 for NO"<<endl; // 加双引号
cin>>l;
if(l==1){
if(k>5){cout<<"Sorry, Economy Seat is full too. Next flight leaves in 3 hours."<<endl;}
else {goto loop1;}
}
if(l==2){cout<<"Next flight leaves in 3 hours."<<endl;}
}
}
if(i<=4||j<=9)goto loop0;
}
} // 漏了个大括号

这样改就可以编译通过了
望采纳
全部回答

cout<<"Economy is full. Do you want First Class Seat? Please type 1 for YES, type 2 for NO"<<endl;

少了个 "

我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
哥哥们,我电脑是惠普的,玩qq炫舞老掉线,跟
既非天纵之才,亦无后天之资。三尺微命,一介
仙剑1里你觉得糖玉小宝和阿奴这段情如何?
小青菜诗歌,关于蔬菜的诗歌
茶具包装城地址在哪,我要去那里办事
汽车网上选号
彭宇现在的发型大家觉得好看吗?
什么是胎盘早熟
人世间什么 最痛苦
我和孩子有户口本但村委把我们当死者了?
岳阳化妆培训学校有好几家,哪家评价好啊?我
中国邮政储蓄银行冲财富通可以吗
DNF改版后漫游和机器谁强
世上有恐龙吗
耳机先锋 ,索尼,联想,飞利浦等 哪款好些啊
推荐资讯
‘上课’英语是什么写?
7年级地理题:
我在社区竞猜中了,怎么领取G币?
波克币怎么获得,智联币多少钱一个
爱护车内环境的标语,表达车行的诗词
什么牌子的网卡网速快?
郑州有什么纯银名店
男,22,湿热体质,请问吃什么药,能缓解
大学六组的口号大全,描写十二班青春励志的运
关于一部小说的名字
织围巾难吗?
工行能不能在柜员机上面直接存款?(是无卡存
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?