Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <iostream>
- #include <conio.h>
- #include <ctime>
- using namespace System;
- using namespace std;
- struct Votantes
- {
- long dni;
- short voto;
- };
- void Spawn_votantes(Votantes *arreglo)
- {
- for (int i = 0; i < 100; ++i)
- {
- arreglo[i].dni = rand() % 1000000 + 10000000;
- arreglo[i].voto = rand() % 3 + 1;
- }
- }
- void cant_votantes(Votantes *arreglo, int *a, int *b, int *c)
- {
- *a = 0;
- *b = 0;
- *c = 0;
- for (int i = 0; i < 100; i++)
- {
- if (arreglo[i].voto == 1)
- {
- (*a)++;
- }
- else if (arreglo[i].voto == 2)
- {
- (*b)++;
- }
- else if (arreglo[i].voto == 3)
- {
- (*c)++;
- }
- }
- }
- void ganador(int c1, int c2)
- {
- if (c1 > c2)
- {
- cout << "Gana el A" << endl;
- }
- else if (c2 > c1)
- {
- cout << "Gana el B" << endl;
- }
- else
- {
- cout << "Empataron" << endl;
- }
- }
- void viejo(Votantes *arreglo)
- {
- long menor = arreglo[0].dni;
- int p = 0;
- for (int i = 0; i < 100; i++)
- {
- if (arreglo[i].dni < menor)
- {
- menor = arreglo[i].dni;
- p + 1;
- }
- }
- cout << "El dni mas logevo es: " << menor << endl;
- cout << "Su posicion es: " << p << endl;
- }
- void mostrar(Votantes *arreglo)
- {
- for (int i = 0; i < 100; i++)
- {
- cout << i << " -> " << arreglo[i].dni << " - " << arreglo[i].voto << endl;
- }
- }
- int main()
- {
- int c1, c2, c3;
- srand(time(0));
- Votantes *arreglo = new Votantes[100];
- Spawn_votantes(arreglo);
- cant_votantes(arreglo, &c1, &c2, &c3);
- cout << "Op 1: " << c1 << endl;
- cout << "Op 2: " << c2 << endl;
- cout << "Op 3: " << c3 << endl;
- ganador(c1, c2);
- viejo(arreglo);
- mostrar(arreglo);
- _getch();
- }
- */
- #include <iostream>
- #include <conio.h>
- #include <ctime>
- using namespace System;
- using namespace std;
- struct Clientes
- {
- char cliente;
- int tramite;
- int tiempo;
- };
- void Spawn_c(Clientes *Vec, int c)
- {
- for (int i = 1; i < c; i++)
- {
- Vec[i].cliente = rand() % 2 == 0 ? 'v' : 'N';
- Vec[i].tramite = rand() % 5 + 1;
- Vec[i].tiempo = rand() % 600 + 60;
- /*
- if (Vec[i].cliente == 'V')
- {
- cout << "VIP";
- }
- else
- {
- cout << "Normal";
- }
- */
- }
- }
- void Mayor_frec(Clientes *Vec, int c)
- {
- int cV = 0;
- int cN = 0;
- for (int i = 0; i < c; i++)
- {
- if (Vec[i].cliente == 'V')
- {
- cV++;
- }
- else
- {
- cN++;
- }
- }
- if (cV > cN)
- {
- cout << "Los usuarios VIP van seguido" << endl;
- }
- else if (cN > cV)
- {
- cout << "Los usuarios NORMALES van seguido" << endl;
- }
- else
- {
- cout << "Ambos van seguido";
- }
- }
- int N_tram(Clientes *Vec, int c)
- {
- float x = 0;
- float prom = 0;
- for (int i = 0; i < c; i++)
- {
- if (Vec[i].tramite == 'V')
- {
- x++;
- prom += Vec[i].tramite;
- }
- }
- return prom/x;
- }
- void mayor(Clientes *Vec, int c)
- {
- int m = Vec[0].tiempo;
- int p = 0;
- for (int i = 0; i < c; i++)
- {
- if (Vec[i].tiempo > m)
- {
- m = Vec[i].tiempo;
- p = i;
- }
- }
- cout << "El mayor es: " << m << "El tipo: " << Vec[p].cliente << "El numero de tramites: " << Vec[p].tramite << endl;
- }
- int main()
- {
- srand(time(0));
- int c = rand() % 41 + 10;
- Clientes *Vec = new Clientes[c];
- Spawn_c(Vec, c);
- Mayor_frec(Vec, c);
- N_tram(Vec, c);
- mayor(Vec, c);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement