Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- libreria
- #pragma once
- #include <iostream>
- using namespace System;
- using namespace std;
- int Menu() {
- int opt;
- cout << "Menu de opciones" << endl;
- cout << "1. Ingresar elemento." << endl;
- //cout << "2. Buscar elemento." << endl;
- //cout << "3. Eliminar elemento." << endl;
- do {
- cout << "Ingrese una opcion: ";
- cin >> opt;
- } while (opt < 0 || opt > 6);
- return opt;
- }
- int* IAF(int *arr, int *cant) {
- Random x;
- int *aux; aux = new int[*cant];
- for (int i = 0;i < *cant;i++) { aux[i] = arr[i]; }
- arr = new int[*cant + 1];
- for (int i = 0;i < *cant;i++) { arr[i] = aux[i]; }
- arr[*cant] = x.Next(10, 99 + 1);
- *cant += 1;
- return arr;
- }
- int* IAI(int *arr, int *cant, int *ind) {
- Random x;
- int *aux; aux = new int[*cant];
- for (int i = 0;i < *cant;i++) { aux[i] = arr[i]; }
- arr = new int[*cant + 1];
- do {
- cout << "Ingrese el indice del valor del dato: ";
- cin >> *ind;
- } while (*ind < 0 || *ind > *cant);
- for (int i = 0;i < *ind;i++) { arr[i] = aux[i]; }
- arr[*ind] = x.Next(10, 99 + 1);
- for (int i = *ind+1;i < *cant;i++) { arr[i] = aux[i]; }
- *cant += 1;
- return arr;
- }
- void Mostrar(int *arr, int *cant) {
- system("cls");
- for (int i = 0;i < *cant;i++) { cout << arr[i] << endl; }
- }
- pagina
- #include <iostream>
- #include <conio.h>
- #include "Header.h"
- using namespace System;
- using namespace std;
- /*
- void Ingresar(int *x) {
- do {
- cout << "Ingrese la cantidad de datos: ";
- cin >> *x;
- } while (*x < 0);
- for (int i = 1; i <= *x; i++) {
- cout << "Ingrese el valor Num " << i << ": ";
- cin >> i;
- }
- }
- */
- void main() {
- int *opt = new int;
- int *arr;
- int *cant_ele = new int;
- int *ind = new int;
- *cant_ele = 0;
- do {
- *opt = Menu();
- if (*opt == 1) { arr = IAF(arr, cant_ele); }
- if (*opt == 4) { Mostrar(arr, cant_ele); }
- if (*opt == 5) { IAI(arr, cant_ele,ind); }
- } while (*opt < 6);
- cout << endl;
- system("pause>0");
- delete[] opt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement