Skip to content

Instantly share code, notes, and snippets.

@graifman
Created May 31, 2016 18:37
Show Gist options
  • Save graifman/9a3d2b352acfeb58e63d3dd078fbbeb3 to your computer and use it in GitHub Desktop.
Save graifman/9a3d2b352acfeb58e63d3dd078fbbeb3 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
struct resultado{
char resul[20];
int mesmo[3]
};
int main()
{
int i;
srand(time(NULL));
struct resultado r[4];
for(i=0;i<3;i++){
r[i].mesmo=rand()%4;
printf("%d : %d",i+1,r[i].mesmo);
}
for(i=0;i<3;i++){
printf("LOTERIA, escolha um dos 4 times abaixo ou Empate\n");
printf("Flor\nAbacaxi\nSupimpa\nSamambaia\n");
gets(r[i].resul);
}
for(i=0;i<3;i++){
if(r[i].mesmo==0){
if(strcmp(r[i].resul,"Flor")==0){
printf("Voce acertou a %d aposta\n",i+1);
}
}
if(r[i].mesmo==1){
if(strcmp(r[i].resul,"Abacaxi")==0){
printf("Voce acertou a %d aposta\n",i+1);
}
}
if(r[i].mesmo==2){
if(strcmp(r[i].resul,"Supimpa")==0){
printf("Voce acertou a %d aposta\n",i+1);
}
}
if(r[i].mesmo==0){
if(strcmp(r[i].resul,"Samambaia")==0){
printf("Voce acertou a %d aposta\n",i+1);
}
}
if(r[i].mesmo==3){
if(strcmp(r[i].resul,"Empate")==0){
printf("Voce acertou a %d aposta\n",i+1);
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment