So I'm trying to do lottery game and I'm supposed to write down top 3 numbers that appeared throughout the game in the Statistics. But I'm not sure how to save or count how many times a number appeared.
int i,s,ans,ans1;
MENU: ;
srand(time(0));
printf("[1]-Play The Game\n[2]-Statistics\n");
scanf(" %d",&ans1);
if(ans1==1){
PLAY: ;
for(i=1;i<=5;i++){
s=1+rand()%9;
printf("%d.number=%d \n",i,s); }
QUESTION: ;
printf("\nWant to roll again? \n [1]-Yes\n[2]-No\nAnswer:");
scanf("%d",&ans);
if(ans==1)
goto PLAY;
else if (ans==2)
goto MENU;
else
goto QUESTION;
}
else if (ans1==2){
printf("\n\t Welcome to Statitistics");
for(int a=0;a<3;a++){
printf("\n%d",s);
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire