-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPABLO_JACOBO2_VOTACION6.cpp
141 lines (113 loc) · 4 KB
/
PABLO_JACOBO2_VOTACION6.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <iostream>
#define LIMITE 2
#define MAGIC_NUMBER 3
using namespace std;
float operativa(){
int opcion = 0;
string n_a, n_b, n_c;
int totx, totb, totc;
int res_a, res_b, res_c;
//Arrays votos
int votos_a[5];
int votos_b[5];
int votos_c[5];
int total[5];
int total_b[5];
int total_c[5];
do{
cout<<"Carnet --> 9490-18-1319"<<endl;
cout<<"Nombre --> Pablo Daniel Jacobo Sanchez"<<endl;
cout<<"Seccion --> D"<<endl;
cout<<""<<endl;
cout<<"Seleccione por quien desea votar !!"<<endl;
cout<<" 1. Cndidato A "<<endl;
cout<<" 2. Candidato B "<<endl;
cout<<" 3. Candidato C "<<endl;
cout<<" 4. Sumas totales "<<endl;
cin>>opcion;
switch(opcion){
case 1:
cout<<" "<<endl;
for(int i = 0; i<=LIMITE; i ++ ){
cout<<"Ingresa un numero de votos "<<endl;
cin>>votos_a[i];
cin.ignore();
cout<<" "<<endl;
}
break;
case 2:
cout<<" "<<endl;
for(int x = 0; x <= LIMITE ; x ++ ){
cout<<"Ingresa un numero de votos "<<endl;
cin>>votos_b[x];
cin.ignore();
cout<<" "<<endl;
}
break;
case 3:
cout<<" "<<endl;
for(int n = 0; n<= LIMITE; n ++ ){
cout<<"Ingresa un numero de votos "<<endl;
cin>>votos_c[n];
cin.ignore();
cout<<" "<<endl;
}
break;
case 4:
cout<<" "<<endl;
//VOTOS A
for(int i=0; i<1; i++){
total[i] = votos_a[0] + votos_a[1] + votos_a[2];
totx = total[i];
}
//VOTOS B
for(int i=0; i<1; i++ ){
total_b[i] = votos_b[0] + votos_b[1] + votos_c[2];
totb = total_b[i];
}
//VOTOS C
for(int i=0; i<1; i++ ){
total_c[i] = votos_c[0] + votos_c[1] + votos_c[2];
totc = total_c[i];
}
cout<<"---------------------------------------------------------------------"<< endl;
cout<<"| Departamentro |Candidato A | Candidato B | Candidato C |"<< endl;
cout<<"--------------------------------------------------------------------"<< endl;
cout<<" "<<" No: 1 "<<" "<<" " << votos_a[0] <<" "<< votos_b[0] <<" "<< votos_c[0] <<endl;
cout<<" "<<" No: 2 "<<" "<<" " << votos_a[1] <<" "<< votos_b[1] <<" "<< votos_c[1] <<endl;
cout<<" "<<" No: 3 "<<" "<<" " << votos_a[2] <<" "<< votos_b[2] <<" "<< votos_c[2] <<endl;
cout<<"---------------------------------------------------------------------"<<endl;
cout<<" "<<" Totales "<<" "<<" " << totx <<" "<< totb <<" "<< totc <<endl;
cout<<"---------------------------------------------------------------------"<<endl;
cout<<" "<<" Porcentajes "<<" "<<" " << totx / MAGIC_NUMBER <<" "<< totb / MAGIC_NUMBER <<" "<< totc / MAGIC_NUMBER <<endl;
cout<<"---------------------------------------------------------------------"<<endl;
//Comparando ganador
if( (totx>totb) && (totx>totc)){
//el primero es ganador
res_a = totx;
cout<<"Gano por la cantidad de: "<< res_a<<endl;
}else if( (totb>totx) && (totb>totc)){
//el segundo es ganador
res_b = totb;
cout<<"Gano por la cantidad de: "<< res_b<<endl;
}else{
//el tercero es ganador
res_c = totc;
cout<<"Gano por la cantidad de: "<< res_c<<endl;
}
cout<<"---------------------------------------------------------------------"<<endl;
cout<<" "<<" Candidato ganador: "<<endl;
cout<<"---------------------------------------------------------------------"<<endl;
break;
default:
cout<<"Ingrese una opcion valida !!"<<endl;
}
}while(opcion != 4 );
}
//Procedimiento
void procedimiento_llamar(){
operativa();
}
int main(){
procedimiento_llamar();
}