Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
【已解决】新手C++学习者的一点问题
Experiences and Insight
297
views ·
4
replies ·
To
floor
Go
Emmmmmmmm
deepin
2019-02-19 03:52
Author
本帖最后由 Emmmmmmmm 于 2019-2-18 20:14 编辑
源程序部分:
int
choose
(string a)
{
int
x;
if
(a==
"end"
)
{
x=
0
;
}
else
(a==
"jia"
)
{
x=
1
;
}
else
(a==
"jian"
)
{
x=
2
;
}
else
(a==
"cheng"
)
{
x=
3
;
}
else
(a==
"shu"
)
{
x=
4
;
}
else
{
x=
666
;
}
return
x;
}
不知道为什么编辑器里粘贴来是有颜色的2333
显示错误信息:
1.cpp:15:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:18:9: error: ‘else’ without a previous ‘if’
else(a=="jian")
^~~~
1.cpp:19:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:22:9: error: ‘else’ without a previous ‘if’
else(a=="cheng")
^~~~
1.cpp:23:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:26:9: error: ‘else’ without a previous ‘if’
else(a=="shu")
^~~~
1.cpp:27:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:30:9: error: ‘else’ without a previous ‘if’
else
^~~~
Reply
Like 0
Favorite
View the author
All Replies
nbxwj
deepin
2019-02-19 04:08
#1
else后再加上 if
Reply
Like 0
View the author
Comments
Emmmmmmmm
2019-02-19 04:13
感谢
魔法师
deepin
2019-02-19 05:36
#2
老哥基础不过关啊,不过有很多坑得踩踩,掉坑里再爬出来就等于成长。
Reply
Like 0
View the author
Ligocut光剪视频剪辑软件
deepin
Backbone of ecological co-construction group
2019-02-19 07:33
#3
else if
Reply
Like 0
View the author
让我康康
deepin
2019-02-19 16:34
#4
新手推荐C++ prime plus
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Events
More
源程序部分:
int choose(string a)
{
int x;
if(a=="end")
{
x=0;
}
else(a=="jia")
{
x=1;
}
else(a=="jian")
{
x=2;
}
else(a=="cheng")
{
x=3;
}
else(a=="shu")
{
x=4;
}
else
{
x=666;
}
return x;
}
不知道为什么编辑器里粘贴来是有颜色的2333
显示错误信息:
1.cpp:15:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:18:9: error: ‘else’ without a previous ‘if’
else(a=="jian")
^~~~
1.cpp:19:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:22:9: error: ‘else’ without a previous ‘if’
else(a=="cheng")
^~~~
1.cpp:23:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:26:9: error: ‘else’ without a previous ‘if’
else(a=="shu")
^~~~
1.cpp:27:9: error: expected ‘;’ before ‘{’ token
{
^
1.cpp:30:9: error: ‘else’ without a previous ‘if’
else
^~~~