Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include<math.h>
  3. using namespace std;
  4. void figura1(int *num) {
  5. for (int i = 1;i <= (*num) * 2 - 1;i++) {
  6. for (int c = 1;c <= (*num) * 2 - 1;c++) {
  7. if (c == *num || i == *num || (c == i || c == (*num) * 2 - i)) {
  8. cout << " " << *num << " ";
  9. }
  10. else cout << " ";
  11. }cout << endl;
  12. }
  13.  
  14. }
  15. void figura2(int *num) {
  16. for (int f = 1;f <= (*num) * 2 - 1;f++) {
  17. for (int c = 1;c <= (*num) * 2 - 1;c++) {
  18. 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)) {
  19. cout << " " << *num << " ";
  20. }else cout << " ";
  21. }cout << endl;
  22. }
  23. }
  24.  
  25.  
  26. int main() {
  27. int n;
  28. cout << "1. Grafico 1 " << endl;
  29. cout << "2. Grafico 2" << endl;
  30. cin >> n;
  31. if (n == 1) {
  32. int *numero = new int;
  33. do {
  34. cout << "Ingresa un numero: ";cin >> *numero;
  35. } while (*numero < 2 && *numero>9);
  36. figura1(numero);delete numero;
  37. }
  38. else if (n == 2) {
  39. int *numero = new int;
  40. do {
  41. cout << "Ingresa un numero: ";cin >> *numero;
  42. } while (*numero < 2 && *numero>9);
  43. figura2(numero);delete numero;
  44. }
  45.  
  46. system("pause > 0");
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement