Advertisement
Courbe_Impliquee

Army

May 24th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <clocale>
  4. #include <iomanip>
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8. setlocale(LC_ALL, "rus");
  9. int r = 0, time = 0, a = 0, b = 0;
  10. char s;
  11. cout << "Поставьте солдат: ";
  12. s = getchar();
  13. do{
  14. if (s == '>'){
  15. a++;
  16. if (b > 0)
  17. b--;
  18. }
  19. else{
  20. r += a;
  21. time = a + b;
  22. if (a > 0)
  23. b++;
  24. }
  25. s = getchar();
  26. } while (s != '\n');
  27. cout << endl;
  28. cout << "Время: " << time << " " << "Кол-во разворотов: " << r <<endl;
  29. system("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement