Skip to content

Instantly share code, notes, and snippets.

@alanneves
Created June 9, 2018 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanneves/4d45d344d1c3159bc63677e7174c23da to your computer and use it in GitHub Desktop.
Save alanneves/4d45d344d1c3159bc63677e7174c23da to your computer and use it in GitHub Desktop.
1
//Alan Neves
//Desenvolvimento de Sistemas
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
void main() {
int v=7,cand1=0,cand2=0,cand3=0,cand4=0,votonulo=0,votoembranco=0,totalvotos;
double por1,por2,por3,por4,por5,por6;
setlocale(LC_ALL,"Portuguese");
printf("INICIE AS VOTAÇÕES!");
while(v!=0){
printf("\n\n1-Lula\n2-Bolsonaro\n3-Ciro Gomes\n4-João Amoedo\n5-Voto Nulo\n6-Voto em Branco");
printf("\nDigite o número correspondente ao seu voto e aperte ENTER");
scanf("%i", &v);
switch(v)
{
case 0:
printf("\nVotação Encerrada!");
break;
case 1:
cand1=cand1+1;
printf("\nLula - VOTO REGISTRADO!");
break;
case 2:
cand2=cand2+1;
printf("\nBolsonaro - VOTO REGISTRADO!");
break;
case 3:
cand3=cand3+1;
printf("\nCiro Gomes - VOTO REGISTRADO!");
break;
case 4:
cand4=cand4+1;
printf("\nJoão Amoedo - VOTO REGISTRADO!");
break;
case 5:
votonulo=votonulo+1;
printf("\nVoto Nulo REGISTRADO!");
break;
case 6:
votoembranco=votoembranco+1;
printf("\nVoto em Branco REGISTRADO!");
break;
default:
printf("Opcão Inválida");
break;
}
}
totalvotos=cand1+cand2+cand3+cand4+votonulo+votoembranco;
por1=(cand1/totalvotos)*100;
por2=(cand2/totalvotos)*100;
por3=(cand3/totalvotos)*100;
por4=(cand4/totalvotos)*100;
por5=(votonulo/totalvotos)*100;
por6=(votoembranco/totalvotos)*100;
printf("\nRESULTADOS:\n Lula\t\t %i\t \n Bolsonaro\t %i\n Ciro Gomes \t %i\n João Amoedo\t %i\n Votos Nulos\t %i\n Votos em Branco %i\n Total de Votos\t %i", cand1,cand2,cand3,cand4,votonulo,votoembranco,totalvotos);
printf("\n\nPERCENTUAL :\n Lula \t\t %lf\n Bolsonaro \t %lf\n Ciro Gomes \t %lf\n João Amoedo \t %lf\n Votos Nulos\t %lf\n Votos em Branco %lf",por1,por2,por3,por4,por5,por6);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment