Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. libreria
  2. #pragma once
  3.  
  4. #include <iostream>
  5.  
  6. using namespace System;
  7. using namespace std;
  8.  
  9. int Menu() {
  10. int opt;
  11.  
  12. cout << "Menu de opciones" << endl;
  13. cout << "1. Ingresar elemento." << endl;
  14. //cout << "2. Buscar elemento." << endl;
  15. //cout << "3. Eliminar elemento." << endl;
  16. do {
  17. cout << "Ingrese una opcion: ";
  18. cin >> opt;
  19. } while (opt < 0 || opt > 6);
  20. return opt;
  21. }
  22.  
  23. int* IAF(int *arr, int *cant) {
  24. Random x;
  25. int *aux; aux = new int[*cant];
  26.  
  27. for (int i = 0;i < *cant;i++) { aux[i] = arr[i]; }
  28. arr = new int[*cant + 1];
  29. for (int i = 0;i < *cant;i++) { arr[i] = aux[i]; }
  30. arr[*cant] = x.Next(10, 99 + 1);
  31. *cant += 1;
  32.  
  33. return arr;
  34. }
  35.  
  36. int* IAI(int *arr, int *cant, int *ind) {
  37. Random x;
  38. int *aux; aux = new int[*cant];
  39.  
  40. for (int i = 0;i < *cant;i++) { aux[i] = arr[i]; }
  41. arr = new int[*cant + 1];
  42.  
  43.  
  44. do {
  45. cout << "Ingrese el indice del valor del dato: ";
  46. cin >> *ind;
  47. } while (*ind < 0 || *ind > *cant);
  48. for (int i = 0;i < *ind;i++) { arr[i] = aux[i]; }
  49. arr[*ind] = x.Next(10, 99 + 1);
  50. for (int i = *ind+1;i < *cant;i++) { arr[i] = aux[i]; }
  51.  
  52.  
  53. *cant += 1;
  54.  
  55. return arr;
  56. }
  57.  
  58. void Mostrar(int *arr, int *cant) {
  59. system("cls");
  60. for (int i = 0;i < *cant;i++) { cout << arr[i] << endl; }
  61.  
  62. }
  63.  
  64.  
  65. pagina
  66.  
  67. #include <iostream>
  68. #include <conio.h>
  69. #include "Header.h"
  70.  
  71. using namespace System;
  72. using namespace std;
  73.  
  74. /*
  75. void Ingresar(int *x) {
  76. do {
  77. cout << "Ingrese la cantidad de datos: ";
  78. cin >> *x;
  79. } while (*x < 0);
  80. for (int i = 1; i <= *x; i++) {
  81. cout << "Ingrese el valor Num " << i << ": ";
  82. cin >> i;
  83. }
  84. }
  85. */
  86.  
  87. void main() {
  88. int *opt = new int;
  89. int *arr;
  90. int *cant_ele = new int;
  91. int *ind = new int;
  92.  
  93. *cant_ele = 0;
  94.  
  95. do {
  96. *opt = Menu();
  97. if (*opt == 1) { arr = IAF(arr, cant_ele); }
  98. if (*opt == 4) { Mostrar(arr, cant_ele); }
  99. if (*opt == 5) { IAI(arr, cant_ele,ind); }
  100.  
  101. } while (*opt < 6);
  102.  
  103.  
  104.  
  105. cout << endl;
  106. system("pause>0");
  107. delete[] opt;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement