2 weird things:
1. That it chooses 1 random number and it's like static for each compilation?
What do I mean?
If you compile/execute it, it choose a random number between 0 to 2, and it's the same one for all of the games.
If you close the window and open a new one, it chooses a random number again between 0 to 2, and does the same thing.
A bit hard to explain, so just compile it.
2. It doesn't show the ERROR::1\2\3 thing, why?
Code:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
int pw=0,cw=0,pp=0,cp=0,t=1,m=100,g;
int main(void)
{
while(m>0)
{
randomize();
clrscr();
printf("---GAME #%d---\n",t);
printf("You have %d $\n",m);
printf("Points situaton:Computer %5d\n\t\tYou %5d\n",cp,pp);
puts("Choose your weapon:\nFor rock O enter 1\nFor paper"
" [] enter 2\nFor scissors 8< enter 3");
scanf("%d", &pw);
if(pw > 3 || pw < 0) puts("ERROR::Use only 1\\2\\3");
if(pw == 1 || pw == 2 || pw == 3)
{
printf("\nHow much money you wanna gamble on?\n");
scanf("%d", &g);
if(g > m) g = m;
if(g < 0) printf("\nOnly native numbers are acceptable.\n");
if(g <= m && g > 0)
{
cw = random(2);
if((cw==0&&pw==1)||(cw==1&&pw==2)||(cw==2&&pw==3))
{
printf("Computer: %d", cw);
puts("Result: equivalent");
t++;
}
if((cw==1&&pw==1)||(cw==2&&pw==2)||(cw==0&&pw==3))
{
printf("Computer: %d", cw);
puts("Computer win.");
cp++;
m=m-g;
t++;
}
if((cw==2&&pw==1)||(cw==0&&pw==2)||(cw==1&&pw==3))
{
printf("Computer: %d", cw);
puts("Player win.");
pp++;
m=m+g;
t++;
}
}
}
}
if(m<=0)
{
puts("The end!!!");
getchar();
}
return 0;
}
Please help, thanks.