Софтуерно Инженерство
Loading...
+ Нов въпрос
LoshaPanda avatar LoshaPanda 5 Точки

Walking problem

Здравейте, 

Имам малък проблем със задачата " Стъпки ", получавам 70/100 и не мога да си намеря проблема. Ще съм благодарен ако някой ми помогне.

 

#include <iostream>
#include <string>


using namespace std;

int main()
{
	
	string decision; int steps, total_s = 0, w_steps = 0;

	cin >> steps;

	cin.ignore();

	while (steps < 10000)
	{
		getline(cin, decision);

		if (decision == "Going home")
		{
			cin >> steps;

			steps += w_steps;

			if (steps < 10000)
			{
				break;
			}

		}
		else {

			int s = stoi(decision); steps += s;
		}
	}

	if (steps >= 10000)
	{
		cout << "Goal reached! Good job!";
	}
	else if (steps < 10000)
	{
		cout << 10000 - steps << " more steps to reach goal.";
	}

}

 

Тагове:
0
Programming Basics
DeveloperEnthusiast avatar DeveloperEnthusiast 273 Точки

Здравей, 

мога да ти помогна с едно примерно решение: https://pastebin.com/EGV0rLhG тъй като има някои неща от кода ти, които не са ми ясни. Дано ти е полезно и се оправиш... smiley

0
ThomasMore avatar ThomasMore -19 Точки

In any case, the expression is real: structure a strong suggestion and procedure explanation and your work will "remain in contact with itself." Plan to contribute some essentialness making and re-trying and modifying (once more) your proposal and framework verbalizations so you will know where you are going and where you have to go. 
By: https://articleoftheweek.com/2020/01/26/what-is-comptia-cdia-certification/

0