C ++中的常见问题 [英] A common problem in C++
问题描述
我正面临一个错误,那就是演示错误。作为一个初学者到c ++,我被困在下面列出的一个问题:
两辆车(X和Y)离开同一个方向。 X车以60 km / h的恒定速度离开,Y车以90 km / h的恒定速度离开。
一小时(60分钟) )Y车可以与X车相距30公里,换句话说,它可以每2分钟逃离一公里。
阅读距离(以km为单位)并计算汽车Y相对于另一辆汽车需要多长时间(以分钟为单位)。
:::输入: ::
30
:::输出::::
60分钟(葡萄牙语分钟数)
我尝试过的事情:
现在,在提交代码后,它会显示错误。所以提前给出一个解决方案。
:::::::::::::::::::::::::::::::::::: :::
I am facing an error, that is presentation error.Being a beginner to c++ , i am stucked on a question which listed below:
Two cars (X and Y) leave in the same direction. The car X leaves with a constant speed of 60 km/h and the car Y leaves with a constant speed of 90 km / h.
In one hour (60 minutes) the car Y can get a distance of 30 kilometers from the X car, in other words, it can get away one kilometer for each 2 minutes.
Read the distance (in km) and calculate how long it takes (in minutes) for the car Y to take this distance in relation to the other car.
:::Input:::
30
:::Output::::
60 minutos (minutes in portuguese)
What I have tried:
Now, upon submitting the code it says presentation error. So give a solution ,thanx in advance.
:::::::::::::::Below my code::::::::::
#include <iostream>
using namespace std;
int main(){
int Y;
cin >> Y ;
cout << 2*Y << " minutos " << endl;
return 2*Y;
}
推荐答案
您的代码是正确的(但主要功能,按惯例,成功时应返回0
:'演示错误'不是C ++
错误,它看起来比赛你提交给你的程序只是不喜欢输出。
Your code is correct (but the main function, by convention, should return0
on success): 'presentation error' is not aC++
error, it looks the contest you are submitting to your program just doesn't like the output.
什么编译器允许这样做没有错误
What compiler is allowing this thru without an error
#include
?????真的通过你的编译器..我被惊呆了
我会因为提交那行代码而彻底失败
可能会问你实际编译代码的问题吗?
????? really gets thru your compiler .. I am stunned
I would fail you outright just for submitting that line of code
Probably begs the question have you actually compiled your code?
这篇关于C ++中的常见问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!