C语言编程设计,分段计算乘坐地铁票价,速度速度~
答案:3 悬赏:20 手机版
解决时间 2021-04-15 02:35
- 提问者网友:棒棒糖
- 2021-04-14 03:53
C语言编程设计,分段计算乘坐地铁票价,速度速度~
最佳答案
- 五星知识达人网友:洒脱疯子
- 2021-04-14 04:28
#include
main()
{
double km;
int price = 0;
scanf("%lf",&km);
if (km >= 0 && km <= 6)
{
price = 3;
}
else if (km > 6 && km <= 16)
{
price = 4;
}
if (km > 16 && km <= 26)
{
price = 5;
}
if (km > 26)
{
price = 6;
}
printf("%d",price);
}
main()
{
double km;
int price = 0;
scanf("%lf",&km);
if (km >= 0 && km <= 6)
{
price = 3;
}
else if (km > 6 && km <= 16)
{
price = 4;
}
if (km > 16 && km <= 26)
{
price = 5;
}
if (km > 26)
{
price = 6;
}
printf("%d",price);
}
全部回答
- 1楼网友:低血压的长颈鹿
- 2021-04-14 05:57
#include
int main(void){
int x=0;
int y=0;
printf("Please input km=");
scanf("%d",&x);
if(x>26){
y=6;
}
else if(x>16){
y=5;
}
else if(x>6){
y=4;
}
else{
y=3;
}
printf("%d公里:地铁票价%d 元\n",x,y);
}追问Cpp1.exe - 20 error(s), 0 warning(s)追答#include
int main(void){
int x=0;
int y=0;
printf("Please input km=");
scanf("%d",&x);
if(x>26){
y=6;
}
else if(x>16){
y=5;
}
else if(x>6){
y=4;
}
else/* if(x>1)*/{
y=3;
}
printf("%d公里: 地铁票价%d 元\n",x,y);
}
int main(void){
int x=0;
int y=0;
printf("Please input km=");
scanf("%d",&x);
if(x>26){
y=6;
}
else if(x>16){
y=5;
}
else if(x>6){
y=4;
}
else{
y=3;
}
printf("%d公里:地铁票价%d 元\n",x,y);
}追问Cpp1.exe - 20 error(s), 0 warning(s)追答#include
int main(void){
int x=0;
int y=0;
printf("Please input km=");
scanf("%d",&x);
if(x>26){
y=6;
}
else if(x>16){
y=5;
}
else if(x>6){
y=4;
}
else/* if(x>1)*/{
y=3;
}
printf("%d公里: 地铁票价%d 元\n",x,y);
}
- 2楼网友:罪歌
- 2021-04-14 04:55
int GetTicketPrice(int km)
{
int price = 0;
if (km >= 1 && km <= 6)
{
price = 3;
}
else if (km > 6 && km <= 16)
{
price = 4;
}
if (km > 16 && km <= 26)
{
price = 5;
}
if (km > 26)
{
price = 6;
}
return price;
}追问error LNK2001: unresolved external symbol _main
Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Cpp1.exe - 2 error(s), 0 warning(s)
{
int price = 0;
if (km >= 1 && km <= 6)
{
price = 3;
}
else if (km > 6 && km <= 16)
{
price = 4;
}
if (km > 16 && km <= 26)
{
price = 5;
}
if (km > 26)
{
price = 6;
}
return price;
}追问error LNK2001: unresolved external symbol _main
Debug/Cpp1.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Cpp1.exe - 2 error(s), 0 warning(s)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯