Advertisement
Guest User

oscar computer inc

a guest
Mar 13th, 2010
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3.  
  4.  main()
  5.  {
  6.        int nvotos,votoa=0,votob=0;
  7.        printf("Porfavor introduzca el numero de votos.");
  8.        
  9.        printf("\n\nNo. de Votos : ");
  10.        scanf("%d", &nvotos);
  11.        printf("\nPara introducir el voto para el candidato A presione 1 y para\n el candidato B presione 2");
  12.        for(int cont=1,decision;cont<=nvotos ;cont++)
  13.        {
  14.                
  15.                printf("\nVoto : %d        Candidato : ", cont);
  16.                scanf("%d", &decision);
  17.               switch (decision)
  18.               {
  19.                      
  20.               case 1 :
  21.                    votoa++;  
  22.                    
  23.                    break;
  24.              
  25.               case 2 :
  26.                    votob++;
  27.              
  28.                    break;
  29.              
  30.               default : printf("Opcion incorrecta\n\n") ;cont--;
  31.                       }
  32.              
  33.               }
  34.               if (votoa>votob) {printf("El ganador es el candidato 1");}
  35.               else if (votob>votoa) {printf("El ganador es el candidato 2");}
  36.               else printf("El ganador es el candidato 2");    
  37.              
  38.       getchar();
  39.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement