Advertisement
Vxzyd

Strzałka w lewo

Jan 26th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void rysuj(int h, int index = 0, int newindex = 0)
  6. {
  7. if ((h / 2) - index >= 0)
  8. {
  9. for (int i = 0; i < ((h / 2) - index); i++)
  10. {
  11. cout << " ";
  12. }
  13. for (int i = 0; i < index; i++)
  14. {
  15. cout << "/";
  16. }
  17. cout << endl;
  18. index++;
  19. rysuj(h, index);
  20. }
  21. else if ((h / 2) - index < 0)
  22. {
  23. for (int i = 0; i < newindex; i++)
  24. {
  25. cout << " ";
  26. }
  27.  
  28. for (int i = 0; i <(h / 2)-newindex; i++)
  29. {
  30. cout << "\\";
  31. }
  32. newindex++;
  33. cout << endl;
  34. if (newindex != h / 2)
  35. {
  36. rysuj(h, index, newindex);
  37. }
  38. }
  39. }
  40.  
  41. int main()
  42. {
  43. int h;
  44. cout << "Wprowadz wysokosc strzalki: ";
  45. cin >> h;
  46. rysuj(h);
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement