Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define TAM 2
- typedef struct {
- int depestadual;
- int depfederal;
- int senador;
- int governador;
- int presidente;
- } eleicao2014;
- eleicao2014 capturavoto(eleicao2014 cap) {
- printf(" ------ OLA ELEITOR! -----\n");
- printf(" -- VOTACAO INICIADA --\n\n");
- printf("INSIRA AGORA SEU VOTO PARA DEPUTADO(A) ESTADUAL (5 NUMEROS): ");
- scanf("%d", &cap.depestadual);
- printf("INSIRA AGORA SEU VOTO PARA DEPUTADO(A) FEDERAL (4 NUMEROS): ");
- scanf("%d", &cap.depfederal);
- printf("INSIRA AGORA SEU VOTO PARA SENADOR(A) (3 NUMEROS): ");
- scanf("%d", &cap.senador);
- printf("INSIRA AGORA SEU VOTO PARA GOVERNADOR(A) (2 NUMEROS)");
- scanf("%d", &cap.governador);
- printf("INSIRA AGORA SEU VOTO PARA PRESIDENTE(A) (2 NUMEROS)");
- scanf("%d", &cap.presidente);
- printf("VOTO REGISTRADO! \n");
- return cap;
- }
- void Imprimevoto(eleicao2014 cap) {
- printf("\n------------------------------------");
- printf("\nDEP. ESTADUAL: %d", cap.depestadual);
- printf("\nDEP. FEDERAL: %d", cap.depfederal);
- printf("\nSENADOR: %d", cap.senador);
- printf("\nGOVERNADOR: %d", cap.governador);
- printf("\nPRESIDENTE %d", cap.presidente);
- printf("\n");
- printf("------------------------------------");
- }
- int main(){
- int contpres99 =0, contgov99 =0;
- eleicao2014 eleitores[TAM];
- int i, j;
- for (i = 0; i < TAM; i++) {
- eleitores[i] = capturavoto(eleitores[i]);
- printf("\n");
- }
- for(i=0; i < TAM; i++){
- if (eleitores[i].governador == 99){
- contgov99++;
- }
- if (eleitores[i].presidente == 99){
- contpres99++;
- }
- }
- for(i=0; i < TAM; i++) {
- printf("\n VOTOS REGISTRADOS, Eleitor %d", i+1);
- Imprimevoto(eleitores[i]);
- printf("\n");
- }
- printf("\VOTOS REGISTRADOS PARA O GOVERNADOR(A) Num. 99: %d", contgov99);
- printf("\nVOTOS REGISTRADOS PARA 0 PRESIDENTE(A) Num. 99: %d", contpres99);
- printf("\n\n-----------------------------------------------\n");
- printf("FIM DE ELEICAO, OBRIGADO POR UTILIZAR!");
- printf("\n-----------------------------------------------\n\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement