Advertisement
Mauriciocaradenepe

e3 PC2

Jun 5th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. void cuadrado(int *l) {
  4. for (int i = 1; i <= *l; i++)
  5. {
  6. for (int j = 1; j <= *l; j++)
  7. {
  8. cout << " *";
  9. }
  10. cout << endl;
  11. }
  12. }
  13. void rectangulo(int *l) {
  14. for (int i = 1; i <= l[0]; i++)
  15. {
  16. for (int j = 1; j <= l[1]; j++)
  17. {
  18. cout << " *";
  19. }
  20. cout << endl;
  21. }
  22. }
  23. void rombo(int *l) {
  24.  
  25. do
  26. {
  27. cout << "Ingrese numero entre los valores de 1 y 11: ";
  28. cin >> *l;
  29. } while (*l<0||*l>11);
  30. for (int i = 1; i <= *l; i++)
  31. {
  32. for (int k = *l - 1; k >= i; k--)
  33. {
  34. cout << " ";
  35. }
  36. for (int j = 1; j <= i; j++)
  37. {
  38. cout << " * ";
  39.  
  40. }
  41. cout << endl;
  42. }
  43. for (int i = 1; i <= *l; i++)
  44. {
  45. for (int k = 1; k <= i; k++)
  46. {
  47. cout << " ";
  48. }
  49. for (int j = *l-1; j >= i; j--)
  50. {
  51. cout << " * ";
  52.  
  53. }
  54.  
  55.  
  56. cout << endl;
  57. }
  58. cin.get();
  59. }
  60.  
  61.  
  62. void menu(int *op) {
  63. cout << "MENU:" << endl;
  64. cout << "1.Cuadrado" << endl;
  65. cout << "2.Rectangulo" << endl;
  66. cout << "3.Rombo" << endl;
  67. do
  68. {
  69. cout << "Ingrese Opcion: ";
  70. cin >> *op;
  71. } while (*op<0 || *op>3);
  72. }
  73. void ingresoDatos(int *l) {
  74. cout << "Ingrese lado 1: ";cin >> l[0];
  75. cout << "Ingrese lado 2: ";cin >> l[1];
  76. }
  77. int main() {
  78. int opcion;
  79. int r;
  80. int *lados = new int[2];
  81. int l;
  82. do
  83. {
  84.  
  85. menu(&opcion);
  86. switch (opcion)
  87. {
  88. case 1:cout << "Ingrese lado: ";cin >> l;cuadrado(&l);break;
  89. case 2:ingresoDatos(lados);
  90. rectangulo(lados);break;
  91. case 3: rombo(&r);
  92. default:
  93. break;
  94.  
  95. }
  96. } while (opcion!=3);
  97.  
  98. cin.get();
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement