Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<math.h>
- using namespace std;
- void figura1(int *num) {
- for (int i = 1;i <= (*num) * 2 - 1;i++) {
- for (int c = 1;c <= (*num) * 2 - 1;c++) {
- if (c == *num || i == *num || (c == i || c == (*num) * 2 - i)) {
- cout << " " << *num << " ";
- }
- else cout << " ";
- }cout << endl;
- }
- }
- void figura2(int *num) {
- for (int f = 1;f <= (*num) * 2 - 1;f++) {
- for (int c = 1;c <= (*num) * 2 - 1;c++) {
- if (c == *num || f == *num || (c == (*num) + 1 - f && f<*num) || (c == *num - 1 + f&&f<*num)|| (c ==f-*num+1&&f>*num)||(f>*num&&f - *num == ((*num) * 2 - 1) - c)) {
- cout << " " << *num << " ";
- }else cout << " ";
- }cout << endl;
- }
- }
- int main() {
- int n;
- cout << "1. Grafico 1 " << endl;
- cout << "2. Grafico 2" << endl;
- cin >> n;
- if (n == 1) {
- int *numero = new int;
- do {
- cout << "Ingresa un numero: ";cin >> *numero;
- } while (*numero < 2 && *numero>9);
- figura1(numero);delete numero;
- }
- else if (n == 2) {
- int *numero = new int;
- do {
- cout << "Ingresa un numero: ";cin >> *numero;
- } while (*numero < 2 && *numero>9);
- figura2(numero);delete numero;
- }
- system("pause > 0");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement