Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <conio.h>
- #include <iostream>
- using namespace std;
- using namespace System;
- void ImprimirMenu(int &opc)
- {
- do {
- cout << "MENU: " << endl << "1. Cuadrado. " << endl << "2. Rectangulo. " << endl << "3. Rombo. " << endl;
- cin >> opc;
- } while (opc != 1 && opc != 2 && opc != 3);
- }
- void ImprimirCuadrado(int a)
- {
- do
- {
- cout << "Ingrese el lado del cuadrado. " << endl;
- cin >> a;
- } while (a <= 0);
- for (int i = 0; i < a; i++)
- {
- for (int j = 0; j < a; j++)
- cout << "* ";
- cout << endl;
- }
- }
- void ImprimirRectangulo(int a, int b)
- {
- do
- {
- cout << "Ingrese el alto del rectangulo. " << endl;
- cin >> a;
- } while (a <= 0);
- do
- {
- cout << "Ingrese el ancho del rectangulo. " << endl;
- cin >> b;
- } while (b <= 0);
- for (int i = 0; i < a; i++)
- {
- for (int j = 0; j < b; j++)
- cout << "* ";
- cout << endl;
- }
- }
- void ImprimirRombo(int a)
- {
- do {
- cout << "Ingrese la diagonal del rombo. " << endl;
- cin >> a;
- } while (a < 1 && a>11);
- for (int i = 0; i < 2*a-1; i++)
- {
- for (int j = 0; j < 2*a-1; j++)
- {
- if (j + 2 > a - i&&j<a + i&&j>i - a&&j < 3 * a - i - 2)
- {
- if (i % 2 == 0 && j % 2 == 0 || i % 2 == 1 && j % 2 == 1)
- if (a % 2 == 1)cout << '*';
- else cout << ' ';
- else
- if (a % 2 == 1) cout << ' ';
- else cout << '*';
- }
- else cout << ' ';
- }cout << endl;
- }
- }
- int main()
- {
- int lado = 0, alto = 0, ancho = 0, diago = 0;
- int opc = 0;
- do {
- ImprimirMenu(opc);
- switch (opc)
- {
- case 1:ImprimirCuadrado(lado); break;
- case 2:ImprimirRectangulo(alto, ancho); break;
- case 3:ImprimirRombo(diago); break;
- }
- } while (opc != 4);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment