Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <clocale>
- #include <iomanip>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(LC_ALL, "rus");
- int r = 0, time = 0, a = 0, b = 0;
- char s;
- cout << "Поставьте солдат: ";
- s = getchar();
- do{
- if (s == '>'){
- a++;
- if (b > 0)
- b--;
- }
- else{
- r += a;
- time = a + b;
- if (a > 0)
- b++;
- }
- s = getchar();
- } while (s != '\n');
- cout << endl;
- cout << "Время: " << time << " " << "Кол-во разворотов: " << r <<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement