d great one
Apprentice
- Joined
- Nov 4, 2007
- Sythe Gold
- 0
- Messages
- 930
Basically the output would be
The program is
I need help, because sometimes when the case has higher value than the banker's offer and I pick 'D' (no deal) I still get to win.
The main problem is I don't get the right result in winning or losing.
Please help me.
If the section forum is wrong, please move and notify me. Thanks.
Welcome to deal or no deal.
Cases are 1 - 14
Enter case number: 4
Banker's offer is 14000
D = Deal N = No Deal
Deal or no deal? n
The case contains 2000
You win
Press any key to continue . . .
The program is
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <conio.h>
int a,b;
main()
{
short unsigned int num = 0;
short unsigned int num2 = 0;
char letter;
loop:
num = 1 + rand() % (14 - 1 + 1);
num2 = 1 + rand() % (14 - 1 + 1);
printf ("Welcome to deal or no deal.\nCases are 1 - 14");
printf ("\nEnter case number: ");
scanf ("%d", &a);
a=num*1000;
printf ("\nBanker's offer is %d", a);
printf ("\nD = Deal N = No Deal\nDeal or no deal? ");
scanf ("%",&letter);
b=num2*1000;
printf ("\nThe case contains %d",b);
switch (letter)
if (letter == 'n' || letter == 'N')
{
if (a < b) goto win;
else if (a > b) goto lose;
else if (a == b) goto same;
}
else if (letter == 'd' || letter == 'D')
{
if (a > b) goto win;
else if (a < b) goto lose;
else if (a == b) goto same;
}
win:
{
printf ("\nYou win\n");
system ("pause");
return 0;
}
lose:
{
printf ("\nYou lost\n");
system ("pause");
return 0;
}
same:
{
printf ("\nBanker's offer and case is just the same\n");
system ("pause");
return 0;
}
getch();
}
I need help, because sometimes when the case has higher value than the banker's offer and I pick 'D' (no deal) I still get to win.
The main problem is I don't get the right result in winning or losing.
Please help me.
If the section forum is wrong, please move and notify me. Thanks.

