Ir ao conteúdo
  • Cadastre-se

lucasstamm

Membro Júnior
  • Posts

    7
  • Cadastrado em

  • Última visita

Reputação

0
  1. Valeo cara é de grande adianto... Se alguém tiver alguma outra forma de implementar os vetores ou alguma outra dica será bem vinda!!
  2. UP! Por favor, alguém me ajudee =/
  3. Olá pessoal, tenho um trabalho para ser feito em C... Trabalho de Progressão Parcial, porém devo faze-lo em vetores. Não sei muita coisa em vetores. Consegui faze-lo sem os vetores. Poderiam me ajudar, por favor? #include <stdio.h> #include <stdlib.h> #include <conio.h> int main(){ float cand, total, i, candt[5],porbranco,pornulo,c1=0,c2=0,c3=0,c4=0,branco=0,nu lo=0; char resposta'n'; system("color 0c"); printf("\nELEICOES.\n\nDIGITE -1 PARA ENCERRAR A VOTACAO\n\n"); system("PAUSE"); system("cls"); system("color 0b"); while(cand!=-1){ printf(":: || ELEICOES 2011 || ::\n\n"); printf("Escolha seu candidato:\n\n"); printf("1 - Marta Suplicy\n2 - Paulo Maluf\n3 - Netinho\n4 - Tiririca\n5 - Branco\n\n "); printf("Escolha o seu candidato: "); scanf("%f",&cand); if(cand==1) scanf("%f",&cand[1]); else if(cand==2) scanf("%f",&cand[2]); else if(cand==3) scanf("%f",&cand[3]); else if(cand==4) scanf("%f",&cand[4]); else if (cand==5) scanf("%f",&cand[5]); printf("\n\n"); system("cls"); printf(":: || ELEICOES 2011 || ::\n\n"); printf("CANDIDATO\n\n"); if(cand==1) { printf("1 - Marta Suplicy\n\n"); printf("Confirmar voto(S/N): "); resp=getche(); if (resposta='s' || resposta='S'){ c1++; printf("\n\n"); } } else if(cand==2){ printf("2 - Paulo Maluf\n\n"); printf("Confirmar voto(S/N): "); resp=getche(); if (resposta='s' || resposta='S'){ c2++; printf("\n\n"); } } else if(cand==3){ printf("3 - Netinho\n\n"); printf("Confirmar voto(S/N): "); resp=getche(); if (resposta='s' || resposta='S'){ c3++; printf("\n\n"); } } else if(cand==4){ printf("4 - Tiririca\n\n"); printf("Confirmar voto(S/N): "); resp=getche(); if (resposta='s' || resposta='S'){ c4++; printf("\n\n"); } } else if(cand==5){ printf("5 - Branco\n\n"); printf("Confirmar voto(S/N): "); resp=getche(); if (resposta='s' || resposta='S'){ branco++; printf("\n\n"); } } else if(cand==-1) break; else if (! (cand==-1 && cand==1 && cand==2 && cand==3 && cand==4) ){ system("cls"); printf("Candidato Invalido\n\n"); printf("Confirmar voto(S/N): "); resp=getche(); if (resposta='s' || resposta='S'){ nulo++; printf("\n\n"); } } if(resposta='n' || resposta='N'){ system("cls"); printf("ESCOLHA NOVAMENTE O CANDIDATO.\n\n"); printf("\n"); system("PAUSE"); system("cls"); } else if(resposta='s' || resposta='S'){ printf("VOTO COMPUTADO COM SUCESSO.\n\n"); system("PAUSE"); system("cls"); } else{ system("cls"); printf("ENTRADA INVALIDA.\n\n"); system("PAUSE"); system("cls"); } } system("cls"); printf("VOTACAO ENCERRADA.\n\n"); system("PAUSE"); system("cls"); total=c1+c2+c3+c4+branco+nulo; if (total==0){ printf("NAO HOUVE VOTACAO"); printf("\n\n"); system("PAUSE"); system("cls"); } else { cand1p=((c1*100)/total); cand2p=((c2*100)/total); cand3p=((c3*100)/total); cand4p=((c4*100)/total); porbranco=((branco*100)/total); pornulo=((nulo*100)/total); } for(i=1;i<=4;i++){ if(c1>=c2 && c1>=c3 && c1>=c4 ){ printf("\n CANDIDATO 1 (MARTA SUPLICY), RECEBEU %.0f VOTOS ",c1); printf("(%.2f)\n\n",cand1p); c1=-1; } else if(c2>=c1 && c2>=c3 && c2>=c4){ printf("CANDIDATO 2 (PAULO MALUF), RECEBEU %.0f votos",c2); printf(" (%.2f)\n\n",cand2p); c2=-1; } else if(c3>=c1 && c3>=c2 && c3>=c4){ printf("CANDIDATO 3 (NETINHO), RECEBEU %.0f votos",c3); printf(" (%.2f)\n\n",cand3p); c3=-1; } else{ printf("CANDIDATO 4 (TIRIRICA), RECEBEU %.0f votos",c4); printf("(%.2f)\n\n",cand4p); c4=-1; } } printf("VOTOS EM BRANCO: %.2f VOTOS",branco); printf(" (%.2f)\n",porbranco); printf("VOTOS INVALIDOS: %.2f VOTOS",nulo); printf(" (%.2f)\n",pornulo); printf("TOTAL DE VOTOS: %.2f\n\n",total); system("PAUSE"); return 0; } valeu Edit: Onde posso aplicar os vetores para a armazenagem das informações? Estou tentando a mais de 2 horas e não consigo =/

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!