elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  alguien me puede ayudar, si pueden reponderme lo antes posible porfa
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: alguien me puede ayudar, si pueden reponderme lo antes posible porfa  (Leído 1,916 veces)
XxKIVEKxX

Desconectado Desconectado

Mensajes: 1


Ver Perfil
alguien me puede ayudar, si pueden reponderme lo antes posible porfa
« en: 16 Febrero 2022, 04:08 am »

estoy haciendo un  programa que permita determinar las posiciones de los equipos en un torneo imaginario similar a la copa América.
el error en que nesecito ayuda:
al final cuando ejecuto el programa no me sale ordenado y en empate me da un error, y tengo que agregarle al menos un arreglo y una estructura. La combinación de ambas también es aceptada.


Código
  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <iostream>
  4. #include <cstring>
  5. #include <vector>
  6. #include <sstream>
  7.  
  8. using namespace std;
  9. string  eq1;
  10. string  eq2;
  11. string  eq3;
  12. string  eq4;
  13.  
  14. void resultados(int bolean1,int bolean2,int bolean3, int bolean4, int emGanPer1[7],int emGanPer2[7],int emGanPer3[7],int emGanPer4[7]){
  15.  
  16. if(bolean1 == 0){
  17.        bolean1 = 4;
  18.    }else if(bolean2 == 0){
  19.        bolean2 = 4;
  20.    }else if(bolean3 == 0){
  21.        bolean3 = 4;
  22.    }else{
  23.        bolean4 = 4;
  24.    }
  25.  
  26.   if(bolean1 == 1){
  27.        cout<<eq1<<": "<<emGanPer1[0]<<"  "<<emGanPer1[2]<<"  "<<emGanPer1[3]<<"  "<<emGanPer1[4]<<"  "<<emGanPer1[5]<<"  "<<emGanPer1[6]<<"  "<<emGanPer1[7]<<endl;
  28.    }else if(bolean2 == 1){
  29.        cout<<eq2<<": "<<emGanPer2[0]<<"    "<<emGanPer2[2]<<"  "<<emGanPer2[3]<<"  "<<emGanPer2[4]<<"  "<<emGanPer2[5]<<"  "<<emGanPer2[6]<<"  "<<emGanPer2[7]<<endl;
  30.    }else if(bolean3 == 1){
  31.        cout<<eq3<<": "<<emGanPer3[0]<<"    "<<emGanPer3[2]<<"  "<<emGanPer3[3]<<"  "<<emGanPer3[4]<<"  "<<emGanPer3[5]<<"  "<<emGanPer3[6]<<"  "<<emGanPer3[7]<<endl;
  32.    }else{
  33.        cout<<eq4<<": "<<emGanPer4[0]<<"    "<<emGanPer4[2]<<"  "<<emGanPer4[3]<<"  "<<emGanPer4[4]<<"  "<<emGanPer4[5]<<"  "<<emGanPer4[6]<<"  "<<emGanPer4[7]<<endl;
  34.    }
  35.  
  36.    if(bolean1 == 2){
  37.        cout<<eq1<<": "<<emGanPer1[0]<<"    "<<emGanPer1[2]<<"  "<<emGanPer1[3]<<"  "<<emGanPer1[4]<<"  "<<emGanPer1[5]<<"  "<<emGanPer1[6]<<"  "<<emGanPer1[7]<<endl;
  38.    }else if(bolean2 == 2){
  39.        cout<<eq2<<": "<<emGanPer2[0]<<"    "<<emGanPer2[2]<<"  "<<emGanPer2[3]<<"  "<<emGanPer2[4]<<"  "<<emGanPer2[5]<<"  "<<emGanPer2[6]<<"  "<<emGanPer2[7]<<endl;
  40.    }else if(bolean3 == 2){
  41.        cout<<eq3<<": "<<emGanPer3[0]<<"    "<<emGanPer3[2]<<"  "<<emGanPer3[3]<<"  "<<emGanPer3[4]<<"  "<<emGanPer3[5]<<"  "<<emGanPer3[6]<<"  "<<emGanPer3[7]<<endl;
  42.    }else{
  43.        cout<<eq4<<": "<<emGanPer4[0]<<"    "<<emGanPer4[2]<<"  "<<emGanPer4[3]<<"  "<<emGanPer4[4]<<"  "<<emGanPer4[5]<<"  "<<emGanPer4[6]<<"  "<<emGanPer4[7]<<endl;
  44.    }
  45.  
  46.    if(bolean1 == 3){
  47.        cout<<eq1<<": "<<emGanPer1[0]<<"    "<<emGanPer1[2]<<"  "<<emGanPer1[3]<<"  "<<emGanPer1[4]<<"  "<<emGanPer1[5]<<"  "<<emGanPer1[6]<<"  "<<emGanPer1[7]<<endl;
  48.    }else if(bolean2 == 3){
  49.        cout<<eq2<<": "<<emGanPer2[0]<<"    "<<emGanPer2[2]<<"  "<<emGanPer2[3]<<"  "<<emGanPer2[4]<<"  "<<emGanPer2[5]<<"  "<<emGanPer2[6]<<"  "<<emGanPer2[7]<<endl;
  50.    }else if(bolean3 == 3){
  51.        cout<<eq3<<": "<<emGanPer3[0]<<"    "<<emGanPer3[2]<<"  "<<emGanPer3[3]<<"  "<<emGanPer3[4]<<"  "<<emGanPer3[5]<<"  "<<emGanPer3[6]<<"  "<<emGanPer3[7]<<endl;
  52.    }else{
  53.        cout<<eq4<<": "<<emGanPer4[0]<<"    "<<emGanPer4[2]<<"  "<<emGanPer4[3]<<"  "<<emGanPer4[4]<<"  "<<emGanPer4[5]<<"  "<<emGanPer4[6]<<"  "<<emGanPer4[7]<<endl;
  54.    }
  55.  
  56.    if(bolean1 == 4){
  57.        cout<<eq1<<": "<<emGanPer1[0]<<"    "<<emGanPer1[2]<<"  "<<emGanPer1[3]<<"  "<<emGanPer1[4]<<"  "<<emGanPer1[5]<<"  "<<emGanPer1[6]<<"  "<<emGanPer1[7]<<endl;
  58.    }else if(bolean2 == 4){
  59.        cout<<eq2<<": "<<emGanPer2[0]<<"    "<<emGanPer2[2]<<"  "<<emGanPer2[3]<<"  "<<emGanPer2[4]<<"  "<<emGanPer2[5]<<"  "<<emGanPer2[6]<<"  "<<emGanPer2[7]<<endl;
  60.    }else if(bolean3 == 4){
  61.        cout<<eq3<<": "<<emGanPer3[0]<<"    "<<emGanPer3[2]<<"  "<<emGanPer3[3]<<"  "<<emGanPer3[4]<<"  "<<emGanPer3[5]<<"  "<<emGanPer3[6]<<"  "<<emGanPer3[7]<<endl;
  62.    }else{
  63.        cout<<eq4<<": "<<emGanPer4[0]<<"    "<<emGanPer4[2]<<"  "<<emGanPer4[3]<<"  "<<emGanPer4[4]<<"  "<<emGanPer4[5]<<"  "<<emGanPer4[6]<<"  "<<emGanPer4[7]<<endl;
  64.    }
  65.  
  66.  
  67. }
  68.  
  69. int main(){
  70.  
  71.  
  72.  
  73.  
  74. cout<<"Dime los nombres de los 4 equipos que participaron en esta face y te dare la puntuacion";
  75.  
  76. cout<<"\n Dame el nombre de el primer equipo :"<<endl;
  77. cin>>eq1;
  78. equipo2:
  79. cout<<"\n Dame el nombre de el segundo equipo :"<<endl;
  80. cin>>eq2;
  81. if (eq1==eq2){
  82. cout<<"este equipo ya existe"<<endl;
  83. goto equipo2;
  84. }
  85. equipo3:
  86. cout<<"\n Dame el nombre de el tercer equipo :"<<endl;
  87. cin>>eq3;
  88. if (eq1==eq3){
  89. cout<<"este equipo ya existe"<<endl;
  90. goto equipo3;
  91. }
  92. else if (eq2==eq3){
  93. cout<<"este equipo ya existe"<<endl;
  94. goto equipo3;
  95. }
  96. equipo4:
  97. cout<<"\n Dame el nombre de el cuarto equipo :"<<endl;
  98. cin>>eq4;
  99. if (eq1==eq4){
  100. cout<<"este equipo ya existe"<<endl;
  101. goto equipo4;
  102. }
  103. else if (eq2==eq4){
  104. cout<<"este equipo ya existe"<<endl;
  105. goto equipo4;
  106. }else if (eq3==eq4){
  107. cout<<"este equipo ya existe"<<endl;
  108. goto equipo4;
  109. }
  110. system("CLS");
  111. cout<<"los equipos que participan en esta face son: "<<eq1<<" ,"<<eq2<<" ,"<<eq3<<" ,"<<eq4<<endl;
  112.  
  113. string eq1p;
  114. string eq3p;
  115. string eq2p;
  116. string eq4p;
  117.  
  118. std::vector<std::string> vctGol1;
  119. std::vector<std::string> vctGolC1;
  120. std::vector<std::string> vctGol3;
  121. std::vector<std::string> vctGolC3;
  122. std::vector<std::string> vctPts1;
  123. std::vector<std::string> vctPts3;
  124. std::vector<std::string> vctGol4;
  125. std::vector<std::string> vctGolC4;
  126. std::vector<std::string> vctGol2;
  127. std::vector<std::string> vctGolC2;
  128. std::vector<std::string> vctPts4;
  129. std::vector<std::string> vctPts2;
  130. std::vector<std::string> vctGan1;
  131. std::vector<std::string> vctGan2;
  132. std::vector<std::string> vctGan3;
  133. std::vector<std::string> vctGan4;
  134.  
  135. cout<<"primera ronda "<<eq1<<" vs "<<eq3<<endl;
  136. cout<<"goles del equipo "<<eq1<<": ";
  137. cin>>eq1p;
  138.  
  139. cout<<"goles del equipo "<<eq3<<": ";
  140. cin>>eq3p;
  141.  
  142. vctGol1.push_back(eq1p);
  143. vctGolC1.push_back(eq3p);
  144. vctGol3.push_back(eq3p);
  145. vctGolC3.push_back(eq1p);
  146.  
  147. if(eq1p>eq3p){
  148. vctPts1.push_back("3");
  149. vctPts3.push_back("0");
  150. vctGan1.push_back(""+eq1);
  151. vctGan3.push_back(""+eq1);
  152. }
  153. else if(eq1p<eq3p){
  154. vctPts1.push_back("0");
  155. vctPts3.push_back("3");
  156. vctGan1.push_back(""+eq3);
  157. vctGan3.push_back(""+eq3);
  158. }else{
  159. vctPts1.push_back("1");
  160. vctPts3.push_back("1");
  161. vctGan1.push_back("");
  162. vctGan3.push_back("");
  163. }
  164.  
  165.  
  166. cout<<"Segunda ronda "<<eq1<<" vs "<<eq2<<endl;
  167. cout<<"goles del equipo "<<eq1<<": ";
  168. cin>>eq1p;
  169.  
  170. cout<<"goles del equipo "<<eq2<<": ";
  171. cin>>eq2p;
  172.  
  173. vctGol1.push_back(eq1p);
  174. vctGolC1.push_back(eq2p);
  175. vctGol2.push_back(eq2p);
  176. vctGolC2.push_back(eq1p);
  177.  
  178. if(eq1p>eq2p){
  179. vctPts1.push_back("3");
  180. vctPts2.push_back("0");
  181. vctGan1.push_back(""+eq1);
  182. vctGan2.push_back(""+eq1);
  183. }
  184. else if(eq1p<eq2p){
  185. vctPts1.push_back("0");
  186. vctPts2.push_back("3");
  187. vctGan1.push_back(""+eq2);
  188. vctGan2.push_back(""+eq2);
  189. }else{
  190. vctPts1.push_back("1");
  191. vctPts2.push_back("1");
  192. vctGan1.push_back("");
  193. vctGan2.push_back("");
  194. }
  195.  
  196.  
  197. cout<<"tercera ronda "<<eq1<<" vs "<<eq4<<endl;
  198. cout<<"goles del equipo "<<eq1<<": ";
  199. cin>>eq1p;
  200.  
  201. cout<<"goles del equipo "<<eq4<<": ";
  202. cin>>eq4p;
  203.  
  204. vctGol1.push_back(eq1p);
  205. vctGolC1.push_back(eq4p);
  206. vctGol4.push_back(eq4p);
  207. vctGolC4.push_back(eq1p);
  208.  
  209. if(eq1p>eq4p){
  210. vctPts1.push_back("3");
  211. vctPts4.push_back("0");
  212. vctGan1.push_back(""+eq1);
  213. vctGan4.push_back(""+eq1);
  214. }
  215. else if(eq1p<eq4p){
  216. vctPts1.push_back("0");
  217. vctPts4.push_back("3");
  218. vctGan1.push_back(""+eq4);
  219. vctGan4.push_back(""+eq4);
  220. }else{
  221. vctPts1.push_back("1");
  222. vctPts4.push_back("1");
  223. vctGan1.push_back("");
  224. vctGan4.push_back("");
  225. }
  226.  
  227. cout<<"cuarta ronda "<<eq2<<" vs "<<eq3<<endl;
  228. cout<<"goles del equipo "<<eq2<<": ";
  229. cin>>eq2p;
  230.  
  231. cout<<"goles del equipo "<<eq3<<": ";
  232. cin>>eq3p;
  233.  
  234. vctGol2.push_back(eq2p);
  235. vctGolC2.push_back(eq3p);
  236. vctGol3.push_back(eq3p);
  237. vctGolC3.push_back(eq2p);
  238.  
  239. if(eq2p>eq3p){
  240. vctPts2.push_back("3");
  241. vctPts3.push_back("0");
  242. vctGan2.push_back(""+eq2);
  243. vctGan3.push_back(""+eq2);
  244. }
  245. else if(eq2p<eq3p){
  246. vctPts2.push_back("0");
  247. vctPts3.push_back("3");
  248. vctGan2.push_back(""+eq3);
  249. vctGan3.push_back(""+eq3);
  250. }else{
  251. vctPts2.push_back("1");
  252. vctPts3.push_back("1");
  253. vctGan2.push_back("");
  254. vctGan3.push_back("");
  255. }
  256. cout<<"quinta ronda "<<eq2<<" vs "<<eq4<<endl;
  257. cout<<"goles del equipo "<<eq2<<": ";
  258. cin>>eq2p;
  259.  
  260. cout<<"goles del equipo "<<eq4<<": ";
  261. cin>>eq4p;
  262.  
  263. vctGol2.push_back(eq2p);
  264. vctGolC2.push_back(eq4p);
  265. vctGol4.push_back(eq4p);
  266. vctGolC4.push_back(eq2p);
  267.  
  268. if(eq2p>eq4p){
  269. vctPts2.push_back("3");
  270. vctPts4.push_back("0");
  271. vctGan2.push_back(""+eq2);
  272. vctGan4.push_back(""+eq2);
  273. }
  274. else if(eq2p<eq4p){
  275. vctPts2.push_back("0");
  276. vctPts4.push_back("3");
  277. vctGan2.push_back(""+eq4);
  278. vctGan4.push_back(""+eq4);
  279. }else{
  280. vctPts2.push_back("1");
  281. vctPts4.push_back("1");
  282. vctGan2.push_back("");
  283. vctGan4.push_back("");
  284. }
  285.  
  286. cout<<"sexta ronda "<<eq3<<" vs "<<eq4<<endl;
  287. cout<<"goles del equipo "<<eq3<<": ";
  288. cin>>eq3p;
  289.  
  290. cout<<"goles del equipo "<<eq4<<": ";
  291. cin>>eq4p;
  292.  
  293. vctGol3.push_back(eq3p);
  294. vctGolC3.push_back(eq4p);
  295. vctGol4.push_back(eq4p);
  296. vctGolC4.push_back(eq3p);
  297.  
  298. if(eq3p>eq4p){
  299. vctPts3.push_back("3");
  300. vctPts4.push_back("0");
  301. vctGan3.push_back(""+eq3);
  302. vctGan4.push_back(""+eq3);
  303. }
  304. else if(eq3p<eq4p){
  305. vctPts3.push_back("0");
  306. vctPts4.push_back("3");
  307. vctGan3.push_back(""+eq4);
  308. vctGan4.push_back(""+eq4);
  309. }else{
  310. vctPts3.push_back("1");
  311. vctPts4.push_back("1");
  312. vctGan3.push_back("");
  313. vctGan4.push_back("");
  314. }
  315.  
  316. system("CLS");
  317.  
  318. //equipo1 vctPts1
  319. int gano=0;
  320. int empato=0;
  321. int perdio=0;
  322. int gf=0;
  323. int gc=0;
  324. int pts=0;
  325. //estadisticas primer equipo
  326. for (int i = 0; i < vctPts1.size(); i++){
  327. if (vctPts1[i]=="3"){
  328. gano++;
  329. pts= pts + 3;
  330. }else if (vctPts1[i]=="1"){
  331. empato++;
  332. pts= pts + 1;
  333. }else{
  334. perdio++;
  335. }
  336.  
  337. int x = 0;
  338. stringstream geek(vctGol1[i]);
  339.     geek >> x;
  340. gf = gf + x;
  341.  
  342. int y = 0;
  343. stringstream geek1(vctGolC1[i]);
  344.     geek1 >> y;
  345. gc = gc + y;
  346. }
  347. int emGanPer1[7] = {gano,empato,perdio,gf,gc,gf-gc,pts};
  348.  
  349. //estadisticas segundo equipo
  350. gano=0; empato=0; perdio=0; gf=0; gc=0; pts=0;
  351. for (int i = 0; i < vctPts2.size(); i++){
  352. if (vctPts2[i]=="3"){
  353. gano++;
  354. pts= pts + 3;
  355. }else if (vctPts2[i]=="1"){
  356. empato++;
  357. pts= pts + 1;
  358. }else{
  359. perdio++;
  360. }
  361.  
  362. int x = 0;
  363. stringstream geek(vctGol2[i]);
  364.     geek >> x;
  365. gf = gf + x;
  366.  
  367. int y = 0;
  368. stringstream geek1(vctGolC2[i]);
  369.     geek1 >> y;
  370. gc = gc + y;
  371. }
  372. int emGanPer2[7] = {gano,empato,perdio,gf,gc,gf-gc,pts};
  373.  
  374. //estadisticas tercer equipo
  375. gano=0; empato=0; perdio=0; gf=0; gc=0; pts=0;
  376. for (int i = 0; i < vctPts3.size(); i++){
  377. if (vctPts3[i]=="3"){
  378. gano++;
  379. pts= pts + 3;
  380. }else if (vctPts3[i]=="1"){
  381. empato++;
  382. pts= pts + 1;
  383. }else{
  384. perdio++;
  385. }
  386.  
  387. int x = 0;
  388. stringstream geek(vctGol3[i]);
  389.     geek >> x;
  390. gf = gf + x;
  391.  
  392. int y = 0;
  393. stringstream geek1(vctGolC3[i]);
  394.     geek1 >> y;
  395. gc = gc + y;
  396. }
  397. int emGanPer3[7] = {gano,empato,perdio,gf,gc,gf-gc,pts};
  398.  
  399. //estadisticas cuarto equipo
  400. gano=0; empato=0; perdio=0; gf=0; gc=0; pts=0;
  401. for (int i = 0; i < vctPts4.size(); i++){
  402. if (vctPts4[i]=="3"){
  403. gano++;
  404. pts= pts + 3;
  405. }else if (vctPts4[i]=="1"){
  406. empato++;
  407. pts= pts + 1;
  408. }else{
  409. perdio++;
  410. }
  411.  
  412. int x = 0;
  413. stringstream geek(vctGol4[i]);
  414.     geek >> x;
  415. gf = gf + x;
  416.  
  417. int y = 0;
  418. stringstream geek1(vctGolC4[i]);
  419.     geek1 >> y;
  420. gc = gc + y;
  421. }
  422. int emGanPer4[7] = {gano,empato,perdio,gf,gc,gf-gc,pts};
  423.  
  424. int tot1 = emGanPer1[6];
  425.    int tot2 = emGanPer2[6];
  426.    int tot3 = emGanPer3[6];
  427.    int tot4 = emGanPer4[6];
  428.    int dif1 = emGanPer1[5];
  429.    int dif2 = emGanPer2[5];
  430.    int dif3 = emGanPer3[5];
  431.    int dif4 = emGanPer4[5];
  432.    int golTf1 = emGanPer1[3];
  433.    int golTf2 = emGanPer2[3];
  434.    int golTf3 = emGanPer3[3];
  435.    int golTf4 = emGanPer4[3];
  436.    int bolean1= 0;
  437.    int bolean2= 0;
  438.    int bolean3= 0;
  439.    int bolean4= 0;
  440.  
  441.    //Primer lugar
  442.    if(tot1>tot2  and tot1>tot3 and tot1>tot4){
  443.        bolean1 = 1;
  444.    }else if(tot2>tot1  and  tot2>tot3 and tot2>tot4 ){
  445.        bolean2 = 1;
  446.    }else if(tot3>tot1 and tot3>tot2 and  tot3>tot4 ){
  447.        bolean3 = 1;
  448.    }else if(tot4>tot1 and tot4>tot2 and  tot4>tot3 ){
  449.        bolean4 = 1;
  450.    }else if(tot1==tot2 and  tot1>tot3 and  tot1>tot4 and tot2>tot3 and  tot2>tot4){
  451.        for (int i = 0; i < vctGan1.size(); i++){
  452.         bolean1 = 0;
  453.            if(vctGan1[i] == eq2){
  454.                bolean3 = 1;
  455.                break;
  456.            }else if(vctGan1[i] != "" && vctGan3[i] ==eq1){
  457.                bolean1 = 1;
  458.                break;
  459.            }
  460.        }
  461.    }else if(tot1==tot3 and  tot1>tot2 and tot3>tot2 and tot1>tot4 and tot3>tot4){
  462.        for (int i = 0; i < vctGan1.size(); i++){
  463.         bolean1 = 0;
  464.            if(vctGan1[i] == eq3){
  465.                bolean3 = 1;
  466.                break;
  467.            }else if(vctGan1[i] != "" && vctGan3[i] ==eq1){
  468.                bolean1 = 1;
  469.                break;
  470.            }
  471.        }
  472.    }else if(tot1==tot4 and  tot1>tot2 and tot1>tot3 and tot4>tot2 and tot4>tot3){
  473.        for (int i = 0; i < vctGan1.size(); i++){
  474.         bolean1 = 0;
  475.            if(vctGan1[i] == eq4){
  476.                bolean4 = 1;
  477.                break;
  478.            }else if(vctGan1[i] != "" && vctGan4[i] ==eq1){
  479.                bolean1 = 1;
  480.                break;
  481.            }
  482.        }
  483.    }else if(tot2==tot3 and  tot2>tot1 and tot2>tot4 and tot3>tot1 and tot3>tot4){
  484.        for (int i = 0; i < vctGan2.size(); i++){
  485.         bolean2 = 0;
  486.            if(vctGan2[i] == eq3){
  487.                bolean3 = 1;
  488.                break;
  489.            }else if(vctGan2[i] != "" && vctGan3[i] ==eq2){
  490.                bolean2 = 1;
  491.                break;
  492.            }
  493.        }
  494.    }else if(tot2==tot4 and  tot2>tot1 and tot2>tot3 and tot4>tot1 and tot4>tot3){
  495.        for (int i = 0; i < vctGan2.size(); i++){
  496.         bolean2 = 0;
  497.            if(vctGan2[i] == eq4){
  498.                bolean4 = 1;
  499.                break;
  500.            }else if(vctGan2[i] != "" && vctGan4[i] ==eq2){
  501.                bolean2 = 1;
  502.                break;
  503.            }
  504.        }
  505.    }else if(tot3==tot4 and  tot3>tot1 and tot3>tot2 and tot4>tot1 and tot4>tot2){
  506.        for (int i = 0; i < vctGan3.size(); i++){
  507.         bolean3 = 0;
  508.            if(vctGan2[i] == eq4){
  509.                bolean4 = 1;
  510.                break;
  511.            }else if(vctGan2[i] != "" && vctGan4[i] ==eq3){
  512.                bolean3 = 1;
  513.                break;
  514.            }
  515.        }
  516.    }
  517. if(tot1==tot2 and tot2==tot3 and tot4<tot3 and bolean1==0 and bolean2==0 and bolean3==0 and bolean4==0){
  518.        if(dif1<dif2 and dif1<dif3){
  519.            bolean1 = 1;
  520.        }else if(dif2<dif1 and dif2<dif3){
  521.            bolean2 = 1;
  522.        }else if(dif3<dif1 and dif3<dif2 ){
  523.            bolean3 = 1;
  524.        }
  525.    }else if(tot2==tot3 and tot3==tot4 and tot1<tot3 and bolean1==0 and bolean2==0 and bolean3==0 and bolean4==0){
  526.        if(dif2<dif3 and dif2<dif4){
  527.            bolean2 = 1;
  528.        }else if(dif3<dif2 and dif3<dif4){
  529.            bolean3 = 1;
  530.        }else if(dif4<dif2 and dif4<dif3 ){
  531.            bolean4 = 1;
  532.        }
  533.    }else if(tot1==tot3 and tot3==tot4 and tot2<tot3 and bolean1==0 and bolean2==0 and bolean3==0 and bolean4==0){
  534.        if(dif1<dif3 and dif1<dif4){
  535.            bolean1 = 1;
  536.        }else if(dif3<dif1 and dif3<dif4 ){
  537.            bolean3 = 1;
  538.        }else if(dif4<dif1 and dif4<dif3 ){
  539.            bolean4 = 1;
  540.        }
  541.    }else if(tot1==tot2 and tot2==tot4 and tot3<tot4 and bolean1==0 and bolean2==0 and bolean3==0 and bolean4==0){
  542.        if(dif1<dif2 and dif1<dif4){
  543.            bolean1 = 1;
  544.        }else if(dif2<dif1 and dif2<dif4){
  545.            bolean2 = 1;
  546.        }else if(dif4<dif1 and dif4<dif2){
  547.            bolean4 = 1;
  548.        }
  549.    }
  550. if(bolean1==0 and bolean2==0 and bolean3==0 and bolean4==0){
  551.        if(golTf1>golTf2 and golTf1>golTf3 and golTf1>golTf4){
  552.            bolean1 = 1;
  553.        }else if(golTf2>golTf1 and golTf2>golTf3 and golTf2>golTf4){
  554.            bolean2 = 1;
  555.        }else if(golTf3>golTf1 and golTf3>golTf2 and golTf3>golTf4){
  556.            bolean3 = 1;
  557.        }else if(golTf4>golTf1 and golTf4>golTf2 and golTf4>golTf3){
  558.            bolean4 = 1;
  559.        }else{
  560.            bolean1 = 1;
  561.        }
  562.    }
  563.  
  564.     //Segundo si el primer lugar gano equipo1
  565.  
  566.    if(bolean1 == 1){
  567.        if(tot2>tot3 and tot2>tot4 ){
  568.            bolean2 = 2;
  569.        }else if(tot3>tot2 and  tot3>tot4 ){
  570.            bolean3 = 2;
  571.        }else if(tot4>tot2 and  tot4>tot3 ){
  572.            bolean4 = 2;
  573.        }else if(tot2==tot3 and tot2>tot4 and tot3>tot4){
  574.            for (int i = 0; i < vctGan2.size(); i++){
  575.             bolean2 = 0;
  576.                if(vctGan2[i] == eq3){
  577.                    bolean3 = 2;
  578.                    break;
  579.                }else if(vctGan2[i] != "" && vctGan3[i] ==eq2){
  580.                    bolean2 = 2;
  581.                    break;
  582.                }
  583.            }
  584.        }else if(tot2==tot4  and tot2>tot3 and tot4>tot3){
  585.            for (int i = 0; i < vctGan2.size(); i++){
  586.             bolean2 = 0;
  587.                if(vctGan2[i] == eq4){
  588.                    bolean4 = 2;
  589.                    break;
  590.                }else if(vctGan2[i] != "" && vctGan4[i] ==eq2){
  591.                    bolean2 = 2;
  592.                    break;
  593.                }
  594.            }
  595.        }else if(tot3==tot4 and   tot3>tot2 and tot4>tot2){
  596.            for (int i = 0; i < vctGan3.size(); i++){
  597.             bolean3 = 0;
  598.                if(vctGan3[i] == eq4){
  599.                    bolean4 = 2;
  600.                    break;
  601.                }else if(vctGan3[i] != "" && vctGan4[i] ==eq3){
  602.                    bolean3 = 2;
  603.                    break;
  604.                }
  605.            }
  606.        }
  607. if(tot2==tot3 and tot3==tot4 and bolean2==0 and bolean3==0 and bolean4==0){
  608.            if(dif2>dif3 and dif2>dif4){
  609.                bolean2 = 2;
  610.            }else if(dif3>dif2 and dif3>dif4){
  611.                bolean3 = 2;
  612.            }else if(dif4>dif2 and dif4>dif3){
  613.                bolean4 = 2;
  614.            }
  615.        }
  616. if(bolean2==0 and bolean3==0 and bolean4==0){
  617.            if( golTf2>golTf3 and golTf2>golTf4){
  618.                bolean2 = 2;
  619.            }else if( golTf3>golTf2 and golTf3>golTf4){
  620.                bolean3 = 2;
  621.            }else if(golTf4>golTf2 and golTf4>golTf3){
  622.                bolean4 = 2;
  623.            }else{
  624.                bolean2 = 2;
  625.            }
  626.        }
  627.    }
  628.  
  629.    //Segundo si el primer lugar gano equipo2
  630.    if (bolean2 == 1){
  631.        if(tot1>tot3 and tot1>tot4){
  632.            bolean1 = 2;
  633.        }else if(tot3>tot1  and  tot3>tot4 ){
  634.            bolean3 = 2;
  635.        }else if(tot4>tot1  and  tot4>tot3 ){
  636.            bolean4 = 2;
  637.        }else if(tot1==tot3 and tot1>tot4 and tot3>tot4){
  638.            for (int i = 0; i < vctGan1.size(); i++){
  639.             bolean1 = 0;
  640.                if(vctGan1[i] == eq3){
  641.                    bolean3 = 2;
  642.                    break;
  643.                }else if(vctGan1[i] != "" && vctGan3[i] ==eq1){
  644.                    bolean1 = 2;
  645.                    break;
  646.                }
  647.            }
  648.        }else if(tot1==tot4  and tot1>tot3 and tot4>tot3){
  649.            for (int i = 0; i < vctGan1.size(); i++){
  650.             bolean1 = 0;
  651.                if(vctGan1[i] == eq4){
  652.                    bolean4 = 2;
  653.                    break;
  654.                }else if(vctGan1[i] != "" && vctGan4[i] ==eq1){
  655.                    bolean1 = 2;
  656.                    break;
  657.                }
  658.            }
  659.        }else if(tot3==tot4 and  tot3>tot1 and tot4>tot1){
  660.            for (int i = 0; i < vctGan3.size(); i++){
  661.             bolean3 = 0;
  662.                if(vctGan3[i] == eq4){
  663.                    bolean4 = 2;
  664.                    break;
  665.                }else if(vctGan3[i] != "" && vctGan4[i] ==eq3){
  666.                    bolean3 = 2;
  667.                    break;
  668.                }
  669.            }
  670.        }
  671. if(tot1==tot3 and tot3==tot4 and bolean1==0 and bolean3==0 and bolean4==0){
  672.            if(dif1>dif3 and dif1>dif4){
  673.                bolean1 = 2;
  674.            }else if(dif3>dif1 and dif3>dif4 ){
  675.                bolean3 = 2;
  676.            }else if(dif4>dif1 and dif4>dif3 ){
  677.                bolean4 = 2;
  678.            }
  679.        }
  680. if(bolean1==0 and bolean3==0 and bolean4==0){
  681.            if(golTf1>golTf3 and golTf1>golTf4){
  682.                bolean1 = 2;
  683.            }else if(golTf3>golTf1 and golTf3>golTf4){
  684.                bolean3 = 2;
  685.            }else if(golTf4>golTf1 and golTf4>golTf3){
  686.                bolean4 = 2;
  687.            }else{
  688.                bolean1 = 2;
  689.            }
  690.        }
  691.    }
  692.  
  693.    //Segundo si el primer lugar gano equipo3
  694.    if(bolean3 == 1){
  695.        if(tot1>tot2   and tot1>tot4){
  696.            bolean1 = 2;
  697.        }else if(tot2>tot1   and tot2>tot4 ){
  698.            bolean2 = 2;
  699.        }else if(tot4>tot1 and tot4>tot2  ){
  700.            bolean4 = 2;
  701.        }else if(tot1==tot2  and  tot1>tot4 and  tot2>tot4){
  702.            for (int i = 0; i < vctGan1.size(); i++){
  703.             bolean1 = 0;
  704.                if(vctGan1[i] == eq2){
  705.                    bolean2 = 2;
  706.                    break;
  707.                }else if(vctGan1[i] != "" && vctGan2[i] ==eq1){
  708.                    bolean1 = 2;
  709.                    break;
  710.                }
  711.            }
  712.        }else if(tot1==tot4 and  tot1>tot2  and tot4>tot2 ){
  713.            for (int i = 0; i < vctGan1.size(); i++){
  714.             bolean1 = 0;
  715.                if(vctGan1[i] == eq4){
  716.                    bolean4 = 2;
  717.                    break;
  718.                }else if(vctGan1[i] != "" && vctGan4[i] ==eq1){
  719.                    bolean1 = 2;
  720.                    break;
  721.                }
  722.            }
  723.        }else if(tot2==tot4 and  tot2>tot1  and tot4>tot1 ){
  724.            for (int i = 0; i < vctGan2.size(); i++){
  725.             bolean2 = 0;
  726.                if(vctGan2[i] == eq4){
  727.                    bolean4 = 2;
  728.                    break;
  729.                }else if(vctGan2[i] != "" && vctGan4[i] ==eq2){
  730.                    bolean2 = 2;
  731.                    break;
  732.                }
  733.            }
  734.        }
  735. if(tot1==tot2 and tot2==tot4  and bolean1==0 and bolean2==0 and bolean4==0){
  736.            if(dif1>dif2 and dif1>dif4){
  737.                bolean1 = 2;
  738.            }else if(dif2>dif1 and dif2>dif4){
  739.                bolean2 = 2;
  740.            }else if(dif4>dif1 and dif4>dif2){
  741.                bolean4 = 2;
  742.            }
  743.        }
  744. if(bolean1==0 and bolean2==0 and bolean4==0){
  745.            if(golTf1>golTf2  and golTf1>golTf4){
  746.                bolean1 = 2;
  747.            }else if(golTf2>golTf1 and golTf2>golTf4){
  748.                bolean2 = 2;
  749.            }else if(golTf4>golTf1 and golTf4>golTf2){
  750.                bolean4 = 2;
  751.            }else{
  752.                bolean1 = 2;
  753.            }
  754.        }
  755.    }
  756.  
  757.     //Segundo si el primer lugar gano equipo4
  758.    if(bolean4 == 1){
  759.        if(tot1>tot2   and tot1>tot3){
  760.            bolean1 = 2;
  761.        }else if(tot2>tot1   and tot2>tot3 ){
  762.            bolean2 = 2;
  763.        }else if(tot3>tot1 and tot3>tot2  ){
  764.            bolean3 = 2;
  765.        }else if(tot1==tot2  and  tot1>tot3 and  tot2>tot3){
  766.            for (int i = 0; i < vctGan1.size(); i++){
  767.             bolean1 = 0;
  768.                if(vctGan1[i] == eq2){
  769.                    bolean2 = 2;
  770.                    break;
  771.                }else if(vctGan1[i] != "" && vctGan2[i] ==eq1){
  772.                    bolean1 = 2;
  773.                    break;
  774.                }
  775.            }
  776.        }else if(tot1==tot3 and  tot1>tot2  and tot3>tot2 ){
  777.            for (int i = 0; i < vctGan1.size(); i++){
  778.             bolean1 = 0;
  779.                if(vctGan1[i] == eq3){
  780.                    bolean3 = 2;
  781.                    break;
  782.                }else if(vctGan1[i] != "" && vctGan3[i] ==eq1){
  783.                    bolean1 = 2;
  784.                    break;
  785.                }
  786.            }
  787.        }else if(tot2==tot3 and  tot2>tot1  and tot3>tot1 ){
  788.            for (int i = 0; i < vctGan2.size(); i++){
  789.             bolean2 = 0;
  790.                if(vctGan2[i] == eq3){
  791.                    bolean3 = 2;
  792.                    break;
  793.                }else if(vctGan2[i] != "" && vctGan3[i] ==eq2){
  794.                    bolean2 = 2;
  795.                    break;
  796.                }
  797.            }
  798.        }
  799. if(tot1==tot2 and tot2==tot3 and bolean1==0 and bolean2==0 and bolean3==0){
  800.            if(dif1>dif2 and dif1>dif3){
  801.                bolean1 = 2;
  802.            }else if(dif2>dif1 and dif2>dif3){
  803.                bolean2 = 2;
  804.            }else if(dif3>dif2 and dif3>dif1){
  805.                bolean3 = 2;
  806.            }
  807.        }
  808. if(bolean1==0 and bolean2==0 and bolean3==0){
  809.            if(golTf1>golTf2  and golTf1>golTf3){
  810.                bolean1 = 2;
  811.            }else if(golTf2>golTf1 and golTf2>golTf3){
  812.                bolean2 = 2;
  813.            }else if(golTf3>golTf1 and golTf3>golTf2){
  814.                bolean3 = 2;
  815.            }else{
  816.                bolean1 = 2;
  817.            }
  818.        }
  819.    }
  820.  
  821.    //Tercer lugar si el eq1 y eq2 ya tienen posicion
  822.    if(bolean1 != 0 and bolean2 !=0){
  823.        if(tot3>tot4 ){
  824.            bolean3 = 3;
  825.        }else if(tot3<tot4 ) {
  826.            bolean4 = 3;
  827.        }else if(tot3==tot4){
  828.            for (int i = 0; i < vctGan3.size(); i++){
  829.             bolean3 = 0;
  830.                if(vctGan3[i] == eq4){
  831.                    bolean4 = 3;
  832.                    break;
  833.                }else if(vctGan3[i] != "" && vctGan4[i] ==eq3){
  834.                    bolean3 = 3;
  835.                    break;
  836.                }
  837.            }
  838.        }
  839. if(tot3==tot4  and bolean4==0 and bolean3==0){
  840.            if(dif3>dif4){
  841.                bolean3 = 3;
  842.            }else if(dif3<dif4){
  843.                bolean4 = 3;
  844.            }
  845.        }
  846. if( bolean4==0 and bolean3==0){
  847.            if(golTf3>golTf4){
  848.                bolean3 = 3;
  849.            }else if(golTf4>golTf3){
  850.                bolean4 = 3;
  851.            }else{
  852.                bolean3 = 3;
  853.            }
  854.        }
  855.    }
  856.  
  857.    //Tercer lugar si el eq1 y eq3 ya tienen posicion
  858.    if(bolean1 != 0 and bolean3 !=0 and bolean2 ==0 and bolean4==0){
  859.        if(tot2>tot4 ){
  860.            bolean2 = 3;
  861.        }else if(tot2<tot4 ) {
  862.            bolean4 = 3;
  863.        }else if(tot2==tot4){
  864.            for (int i = 0; i < vctGan2.size(); i++){
  865.             bolean2 = 0;
  866.                if(vctGan2[i] == eq4){
  867.                    bolean4 = 3;
  868.                    break;
  869.                }else if(vctGan2[i] != "" && vctGan4[i] ==eq2){
  870.                    bolean2 = 3;
  871.                    break;
  872.                }
  873.            }
  874.        }
  875. if(tot2==tot4  and bolean4==0 and bolean2==0){
  876.            if(dif2>dif4 ){
  877.                bolean2 = 3;
  878.            }else if (dif2<dif4 ){
  879.                bolean4 = 3;
  880.            }
  881.        }
  882. if(bolean4==0 and bolean2==0){
  883.            if(golTf2>golTf4){
  884.                bolean2 = 3;
  885.            }else if(golTf4>golTf3){
  886.                bolean4 = 3;
  887.            }else{
  888.                bolean2 = 3;
  889.            }
  890.        }
  891.    }
  892.  
  893.    //Tercer lugar si el eq1 y eq4 ya tienen posicion
  894.    if(bolean1 != 0 and bolean4 !=0 and bolean2 ==0 and bolean3==0){
  895.        if(tot2>tot3 ){
  896.            bolean2 = 3;
  897.        }else if(tot2<tot4 ) {
  898.            bolean3 = 3;
  899.        }else if(tot2==tot3){
  900.            for (int i = 0; i < vctGan2.size(); i++){
  901.             bolean2 = 0;
  902.                if(vctGan2[i] == eq3){
  903.                    bolean3 = 3;
  904.                    break;
  905.                }else if(vctGan2[i] != "" && vctGan3[i] ==eq2){
  906.                    bolean2 = 3;
  907.                    break;
  908.                }
  909.            }
  910.        }
  911. if(tot2==tot3  and bolean2==0 and bolean3==0){
  912.            if(dif2>dif3 ){
  913.                bolean2 = 3;
  914.            }else if(dif2<dif3 ){
  915.                bolean3 = 3;
  916.            }
  917.        }
  918. if( bolean2==0 and bolean3==0){
  919.            if(golTf2>golTf3){
  920.                bolean2 = 3;
  921.            }else if(golTf3>golTf2){
  922.                bolean3 = 3;
  923.            }else{
  924.                bolean2 = 3;
  925.            }
  926.        }
  927.    }
  928.  
  929.    //Tercer lugar si el eq2 y eq3 ya tienen posicion
  930.    if(bolean2 != 0 and bolean3 !=0 and bolean1 ==0 and bolean4==0){
  931.        if(tot1>tot4 ){
  932.            bolean1 = 3;
  933.        }else if(tot1<tot4 ){
  934.            bolean4 = 3;
  935.        }else if(tot1==tot4){
  936.            for (int i = 0; i < vctGan1.size(); i++){
  937.             bolean1 = 0;
  938.                if(vctGan1[i] == eq4){
  939.                    bolean4 = 3;
  940.                    break;
  941.                }else if(vctGan1[i] != "" && vctGan4[i] ==eq1){
  942.                    bolean1 = 3;
  943.                    break;
  944.                }
  945.            }
  946.        }
  947. if(tot1==tot4 and bolean1==0 and bolean4==0){
  948.            if(dif1>dif4 ){
  949.                bolean1 = 3;
  950.            }else if(dif1<dif4 ){
  951.                bolean4 = 3;
  952.            }
  953.        }
  954. if(bolean1==0 and bolean4==0){
  955.            if(golTf1>golTf4){
  956.                bolean1 = 3;
  957.            }else if(golTf4>golTf1){
  958.                bolean4 = 3;
  959.            }else{
  960.                bolean1 = 3;
  961.            }
  962.        }
  963.    }
  964.  
  965.    //Tercer lugar si el eq2 y eq4 ya tienen posicion
  966.    if(bolean2 != 0 and bolean4 !=0 and bolean1 ==0 and bolean3==0){
  967.        if(tot1>tot3 ){
  968.            bolean1 = 3;
  969.        }else if(tot1<tot3) {
  970.            bolean3 = 3;
  971.        }else if(tot1==tot3){
  972.            for (int i = 0; i < vctGan1.size(); i++){
  973.             bolean1 = 0;
  974.                if(vctGan1[i] == eq3){
  975.                    bolean3 = 3;
  976.                    break;
  977.                }else if(vctGan1[i] != "" && vctGan3[i] ==eq1){
  978.                    bolean1 = 3;
  979.                    break;
  980.                }
  981.            }
  982.        }
  983. if(tot1==tot3  and bolean1==0 and bolean3==0){
  984.            if(dif1>dif3 ){
  985.                bolean1 = 3;
  986.            }else if(dif1<dif3 ){
  987.                bolean3 = 3;
  988.            }
  989.        }
  990. if(bolean1==0 and bolean3==0){
  991.            if(golTf1>golTf3){
  992.                bolean1 = 3;
  993.            }else if(golTf3>golTf1){
  994.                bolean3 = 3;
  995.            }else{
  996.                bolean1 = 3;
  997.            }
  998.        }
  999.    }
  1000.  
  1001.    //Tercer lugar si el eq3 y eq4 ya tienen posicion
  1002.    if(bolean3 != 0 and bolean4 !=0 and bolean1 ==0 and bolean2==0){
  1003.        if(tot1>tot2 ){
  1004.            bolean1 = 3;
  1005.        }else if(tot1<tot2 ){
  1006.            bolean2 = 3;
  1007.        }else if(tot1==tot2){
  1008.            for (int i = 0; i < vctGan1.size(); i++){
  1009.             bolean1 = 0;
  1010.                if(vctGan1[i] == eq2){
  1011.                    bolean2 = 3;
  1012.                    break;
  1013.                }else if(vctGan1[i] != "" && vctGan2[i] ==eq1 ){
  1014.                    bolean1 = 3;
  1015.                    break;
  1016.                }
  1017.            }
  1018.        }
  1019. if(tot1==tot2 and bolean1==0 and bolean2==0){
  1020.            if(dif1>dif2 ){
  1021.                bolean1 = 3;
  1022.            }else if(dif1<dif2 ){
  1023.                bolean2 = 3;
  1024.            }
  1025.        }
  1026. if(bolean1==0 and bolean2==0){
  1027.            if(golTf1>golTf2){
  1028.                bolean1 = 3;
  1029.            }else if(golTf2>golTf1){
  1030.                bolean2 = 3;
  1031.            }else{
  1032.                bolean1 = 3;
  1033.            }
  1034.        }
  1035.    }
  1036.  
  1037.    if(bolean1 == 0){
  1038.        bolean1 = 4;
  1039.    }else if(bolean2 == 0){
  1040.        bolean1 = 4;
  1041.    }else if(bolean3 == 0){
  1042.        bolean1 = 4;
  1043.    }else{
  1044.        bolean1 = 4;
  1045.    }
  1046.   cout<<"Pais Ganados Perdidos GF GC DIF Pts Empatados"<<endl;
  1047.   resultados(bolean1,bolean2,bolean3,bolean4,emGanPer1,emGanPer2,emGanPer3,emGanPer4);
  1048.  
  1049.  
  1050.  
  1051.    }

Mod: Etiqueta GeSHi


« Última modificación: 16 Febrero 2022, 13:49 pm por MCKSys Argentina » En línea

@XSStringManolo
Hacker/Programador
Colaborador
***
Desconectado Desconectado

Mensajes: 2.397


Turn off the red ligth


Ver Perfil WWW
Re: alguien me puede ayudar, si pueden reponderme lo antes posible porfa
« Respuesta #1 en: 16 Febrero 2022, 17:38 pm »

Simplifica la lógica y utiliza funciones para reducir el código. Este programa no debería tener mas de 200 lineas de código.


En línea

Mi perfil de patrocinadores de GitHub está activo! Puedes patrocinarme para apoyar mi trabajo de código abierto 💖

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines