Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- main()
- {
- int nvotos,votoa=0,votob=0;
- printf("Porfavor introduzca el numero de votos.");
- printf("\n\nNo. de Votos : ");
- scanf("%d", &nvotos);
- printf("\nPara introducir el voto para el candidato A presione 1 y para\n el candidato B presione 2");
- for(int cont=1,decision;cont<=nvotos ;cont++)
- {
- printf("\nVoto : %d Candidato : ", cont);
- scanf("%d", &decision);
- switch (decision)
- {
- case 1 :
- votoa++;
- break;
- case 2 :
- votob++;
- break;
- default : printf("Opcion incorrecta\n\n") ;cont--;
- }
- }
- if (votoa>votob) {printf("El ganador es el candidato 1");}
- else if (votob>votoa) {printf("El ganador es el candidato 2");}
- else printf("El ganador es el candidato 2");
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement