-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBumpsintheRoad.cpp
More file actions
39 lines (35 loc) · 891 Bytes
/
BumpsintheRoad.cpp
File metadata and controls
39 lines (35 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
string bumps(string road)
{
int count = 0;
string result;
for (int i = 0; i < road.size(); i++)
{
if (road[i] == 'n')
{
count++;
}
}
if (count < 16)
{
result = "Woohoo!";
}
else
{
result = "Car Dead";
}
return result;
}
int main() {
cout << bumps("nnn_n__n_n___nnnnn___n__nnn__");
return 0;
}
/*Description:
Your car is old, it breaks easily. The shock absorbers are gone and you think it can handle about 15 more bumps before it dies totally.
Unfortunately for you, your drive is very bumpy! Given a string showing either flat road (_) or bumps (n). If you are able to reach home safely by encountering 15 bumps or less, return Woohoo!, otherwise return Car Dead
Fundamentals
Strings*/