Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int x, y, s;
- cout << "Wprowadz wysokosc duzego prostokata: ";
- cin >> y;
- cout << "Wprowadz szerokosc duzego prostokata: ";
- cin >> x;
- cout << "Wprowadz wysokosc malego kwadratu: ";
- cin >> s;
- if (x > 0 && y > 0 && s >= 0) {
- if (x >= s && y >= s) {
- for (int kolumny = 0; kolumny < y; kolumny++) {
- for (int wiersze = 0; wiersze < x; wiersze++) {
- if (((kolumny == 0)&&(y>s)) || ((wiersze == 0)&&(x>s)) || ((wiersze == x - 1) && (kolumny + s) < y) || ((kolumny == y - 1) && ((wiersze + s) < x))) {
- cout << "X";
- }
- else if ((kolumny >= (y - s)) && (wiersze >= (x - s))) {
- cout << "O";
- }
- else {
- cout << " ";
- }
- }
- cout << endl;
- }
- }
- else {
- cout << "S nie moze byc wieksze od x lub y" << endl;
- }
- }
- else cout << "Niepoprawne dane!" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement