Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int x, y, s;
  5. cout << "Wprowadz wysokosc duzego prostokata: ";
  6. cin >> y;
  7. cout << "Wprowadz szerokosc duzego prostokata: ";
  8. cin >> x;
  9. cout << "Wprowadz wysokosc malego kwadratu: ";
  10. cin >> s;
  11. if (x > 0 && y > 0 && s >= 0) {
  12. if (x >= s && y >= s) {
  13. for (int kolumny = 0; kolumny < y; kolumny++) {
  14. for (int wiersze = 0; wiersze < x; wiersze++) {
  15. if (((kolumny == 0)&&(y>s)) || ((wiersze == 0)&&(x>s)) || ((wiersze == x - 1) && (kolumny + s) < y) || ((kolumny == y - 1) && ((wiersze + s) < x))) {
  16. cout << "X";
  17. }
  18. else if ((kolumny >= (y - s)) && (wiersze >= (x - s))) {
  19. cout << "O";
  20. }
  21. else {
  22. cout << " ";
  23. }
  24. }
  25. cout << endl;
  26. }
  27. }
  28. else {
  29. cout << "S nie moze byc wieksze od x lub y" << endl;
  30. }
  31. }
  32. else cout << "Niepoprawne dane!" << endl;
  33.  
  34. system("pause");
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement