i revised it a little more...
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <windows.h> #include <conio.h> int main (void) { char response[10]; int n=0; int n2=0; int picknum=0; int picks[20]; int randomnumbers[20]; int correct=0; float bet=0; float winnings=100;
srand(time(NULL)); //Seed the random nubmer generator do{ n=0; n2=0; correct=0; printf("How many numbers do you want to pick? (1-20)\n \n \t - "); scanf("%d", &picknum); if(picknum>20) picknum=20; if(picknum<1) picknum=1; Beep(600, 100); system("CLS"); do{ printf("What is your bet? You have %f credits\n \n \t - ", winnings); scanf("%f", &bet); Beep(600, 100); system("CLS"); printf("Type the numbers you want to pick. After every number, hit enter.\n Repeat as nessissary.\n \n"); }while(bet>winnings); while(n<picknum)
{ scanf("%d", picks+n); if(picks[n]<80&&picks[n]>0) n++; } n=0; while(n<20) { int test=rand()%80+1; while(n2<n) //Check every value to make sure it isn't a duplicate { if(test==randomnumbers[n2]) break; n2++; } if(n2==n)//If the while loop didn't break, they would be equal { randomnumbers[n]=test; n++; } n2=0; } n=0; n2=0; while(n<picknum) { while(n2<20) { if(picks[n]==randomnumbers[n2]) correct++; n2++; } n2=0; n++; }
//Don't know the scoring formula. Paste it here. winnings+=((picknum*bet*correct)/10); printf("You had %i correct. Your current number of credits is %f. Continue?(Y/N)\n \n \t - ", correct, winnings); scanf("%s", response); Beep(600, 100); system("CLS"); if(response[0]=='N' || response[0]=='n') break; }while(winnings>0); printf("You have won %i credits", winnings); }
is there any way to make it so that you wont win any money and will lose your bet if you dont get enough numbers right???
matt wuz here
|