I am programming a deal or no deal game for class. I am stuck at the point after a person "opens" a case. I can get the program to display the proper case number and hidden value, I can also get the program to recognize that that particular case is gone, but not that prize.
For example, if the $500 prize is gone, the computer cannot list it. here are my functions.
The code to open a case
Code:
void open (int cases[], int arraylength){
int i= 0;
int sentinal=0;
int j = 0;
int k = 0;
while(sentinal==0 ){
printf("\nChoose a case 1-10\n");
scanf("%d",&i);
if(1>i || i>10){
printf("Out of range, try again");
}
else{
if(cases[i]==0){
printf("Already opened, try again");
}
else{
printf("Case %d had $%d\n", i, cases[i-1]);
cases[i-1]=0;
sentinal++;
}
}
}
}
the code to list remaining case numbers
Code:
void unopenedcases (int cases[], int arraylength){
int sentinal = 0;
int i = 0;
printf ("\n");
for (i=0; i<SIZE; i++){
sentinal = 0;
while (sentinal==0){
if (cases[i]!=0){
printf("%d ", i+1);
sentinal = 1;
}
else{
sentinal = 1;
}
}
}
printf ("\n");
}
and the problem code, to display remaining prizes
Code:
void prizelook (int cases[], int prizes[], int arraylength){
int i = 0;
int j = 0;
while(i<SIZE ){
if (prizes [i] == cases [j]){
printf ("$%d ", prizes[i]);
i++;
}
else{
j++;
}
}
printf ("\n");
}
Any ideas?