Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(int argc, char const *argv[])
- {
- int voto = 0;
- int votantes = 0;
- int opc1 = 0, opc2 = 0, opc3 = 0, opc4 = 0, opc5 = 0, opc6 = 0;
- int percent1 = 0, percent2 = 0, percent3 = 0, percent4 = 0, percent5 = 0, percent6 = 0;
- int i = 0;
- printf("Insira a quantidade de pessoas que irao votar\n");
- scanf("%d", &votantes);
- for(i = 0; i < votantes; i++)
- {
- printf("Qual a melhor unidade para servers (Votante numero %d) \n", i+1);
- printf("1 - Windows server\n");
- printf("2 - Unix\n");
- printf("3 - linux\n");
- printf("4 - netware\n");
- printf("5- mac\n");
- printf("6 - outro\n");
- scanf("%d", &voto);
- switch(voto){
- case 1:
- printf("Voto registrado opc 1\n");
- opc1++;
- break;
- case 2:
- printf("Voto registrado opc 2\n");
- opc2++;
- break;
- case 3:
- printf("Voto registrado opc 3\n");
- opc3++;
- break;
- case 4:
- printf("Voto registrado opc 4\n");
- opc4++;
- break;
- case 5:
- printf("Voto registrado opc 5\n");
- opc5++;
- break;
- case 6:
- printf("Voto registrado opc 6\n");
- opc6++;
- break;
- default:
- printf ("Valor invalido!\n");
- }
- }
- percent1 = (opc1 / votantes) * 100;
- percent2 = (opc2 / votantes) * 100;
- percent3 = (opc3 / votantes) * 100;
- percent4 = (opc4 / votantes) * 100;
- percent5 = (opc5 / votantes) * 100;
- percent6 = (opc6 / votantes) * 100;
- printf("[Windows server] %d votos e %d porcento\n", opc1, percent1);
- printf("[Unix] %d votos e %d porcento\n", opc2, percent2);
- printf("[Linux] %d votos e %d porcento\n", opc3, percent3);
- printf("[Netware] %d votos e %d porcento\n", opc4, percent4);
- printf("[Mac OS] %d votos e %d porcento\n", opc5, percent5);
- printf("[Outros] %d votos e %d porcento\n", opc6, percent6);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement