Code:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <time.h>
double rand_mid(int low, int high)
{
return (double)(rand()%(high-low+1)+low);
}
int main(){
long int a[26]={1,5,10,25,50,75,100,150,200,250,300,400,500,1000,2500,
5000,10000,25000,50000,75000,100000,250000,500000,1000000,2000000,3000000};
long int b[26];
int bripcase[11]={0,10,100,500,1000,5000,10000,50000,100000,200000,500000};
int bcase[11]={0,0,0,0,0,0,0,0,0,0,0};
int briefcase,remainingCase,choice,mainBriefcase;
int ctr,ctr2,i,o,p,noDeal,roundNum,isWin,isLost;
char *roundWord[11]={"","first","second","third","fourth","fifth",
"sixth","seventh","eight","ninth","tenth"};
srand(time(NULL));
i = rand();
o = rand();
p = rand();
for(ctr=0;ctr<26;ctr++) {
//again:
b[ctr]=a[rand()%100];
//for(ctr2=ctr-1;ctr2>=0;ctr2--){
// if(b[ctr] == b[ctr2])
// goto again;
//}
}
printf("LET'S PLAY. . .\n");
printf("\n*********************");
printf("\n**** DEAL *****");
printf("\n**** OR *****");
printf("\n**** NO DEAL *****");
printf("\n*********************\n\n");
for(i=0;i<10;i++) {
if (bcase[i] ==0) {
printf("[ %d ]\t\t",i+1);
}
else {
printf("[ ]\t\t");
printf("\n\n%d",bcase[i+1]);
}
}
printf("\nSo what's your main briefcase? ");
scanf("%d",&mainBriefcase);
printf("You have chosen your briefcase.");
printf("Press any key to continue...");
_getch();
isLost=0;
isWin=0;
roundNum=0;
noDeal=1;
remainingCase=9;
while (remainingCase != 0 && noDeal == 1) {
printf("\n\n\n deal or no deal %s round\n",roundWord[++roundNum]);
printf("Offer of banker is %d, deal or no deal? 1 or 0\n", i);
scanf("%d", &choice);
printf("Please choose a briefcase: ");
scanf("%d",&choice);
bcase[choice]=1; //0=not opened, 1=opened
//other logic here to finish out a round.
if(roundNum>9) {
isWin=1;
}
if(choice == 1 || isWin == 1)
{
printf("Thank you for playing the game ");
printf("You've just won : %d", a[26]);
_getch();
}
}
return(0);
}
If you need to ask questions, ask away, but DON'T return your program back to the way it was. Learn to use C! We're glad to help.