Reginaldojs

exercicio 30,lista 3

Aug 21st, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include <string.h>
  4. int main(){
  5.     int i;
  6.     char nome[3][30];
  7.     printf("Ola,voce agora estara ajudando a eleger um cadidado!!!\n\n");
  8.     printf("voce ira digitar o nome de tres candidatos:\n");
  9.     int joao,jose,pedro,votoBranco;
  10.     for(i=0;i<3;i++){
  11.        printf("Por favor,entre com o candidato %d:",i+1);
  12.        fgets(nome[i],30,stdin);
  13.        if(nome[i][30]==joao)
  14.        joao++;
  15.        if(nome[i][30]==jose)
  16.        jose++;
  17.        if(nome[i][30]==pedro)
  18.        pedro++;
  19.        if(nome[i][30]==votoBranco)
  20.        votoBranco++;
  21.     }
  22.     printf("Joao recebeu %.0d votos\n",joao);
  23.     printf("Jose recebeu %.0d votos\n",jose);
  24.     printf("Pedro recebeu %.0d votos\n",pedro);
  25.     printf("temos %.0d votos em branco\n",votoBranco);
  26.     system("pause");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment