【题意】:一个高168英尺的船(或者类似的),是否能撞上高为a,b,c的underpasses。思路:三个数比较大小,理解题意就行。
【代码:AC】
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()
{
const int s = 168;
int a = 0, b = 0, c = 0;
while (cin >> a >> b >> c)
{
if (a < s)
cout << "CRASH " << a << endl;
else if (b < s)
cout << "CRASH " << b << endl;
else if (c < s)
cout << "CRASH " << c << endl;
else
cout << "CRASH NO CRASH" << endl;
}
return 0;
}
船只过桥碰撞检测

本文介绍了一个简单的程序设计问题——判断一艘高度为168英尺的船能否顺利通过高度分别为a、b、c的三个桥洞。通过比较船的高度与桥洞高度,程序能够判断是否会发成碰撞。
2336

被折叠的 条评论
为什么被折叠?



