c언어 질문이요(도박게임?)(스압!)
핫블루
질문 제목 :
코드를 실행시키면 while문이 한번돌고 끝나버립니다.그리고 제가압축할시간이 없어서... 정말죄송합니다.... 일단 그냥 복붙해서 올릴께요
질문 내용 :
#include stdio.h
#include stdlib.h
#include time.h
int main(void)
{
int i, j;
int money;
int ops=7;
int user;
int com, u;
int me, comoney;
int count=0;
while(ops==7)
{
sel:
srand((int)time(null));
printf(홀짝게임입니다.\n);
printf(-------------rule---------------------------------------------------\n);
printf(1.당신과 ai둘다 질시 내기에건돈+400만큼 서로잃습니다.\n);
printf(2.당신이돈을 모두잃을시, 게임에서 패배하고 자동으로 종료됩니다.\n);
printf(3.당신이ai를 이길시, 다음모드가 해제됩니다.\n);
printf(-------------------------------------------------------------------\n);
printf(난이도선택(당신의 소지금/컴퓨터 소지금):\n);
printf((현재포인트=%d) lv.2:1포인트때 언락/ lv.3:2포인트때 언락/ lv.4:3포인트때 언락/ \nlv.5:4포인트때 언락/ lv.6:7포인트때 언락\n, count);
printf(-----------------------------------------------------------------------------\n);
printf(1.매우쉬움(10000/3000원) 2.쉬움(7000/4500원)[잠김] 3.보통(5000/5000원)[잠김] \n4.어려움(3000/7000원)[잠김] 5.매우어려움(1000/9000원)[잠김] \n6.헬모드(1000/10000원)[잠김] 7.종료 \n);
printf(-----------------------------------------------------------------------------\n);
scanf(%d, &ops);
if(ops==1)
{
me=10000;
comoney=3000;
printf(점당 얼마를걸지 입력하세요.);
scanf(%d, &money);
printf(당신: 10000/ai: 3000을 가지고 점당 %d만큼 걸고시작합니다.\n, money);
do
{
i=rand()%2;
com=rand()%2;
printf(1또는0을 입력하세요.\n);
scanf(%d, &u);
if(u==i)
{
if(com==i)
printf(비겼습니다.\n);
else
{
printf(이겼습니다(+%d원)!\n, money);
if(com!=i){
com=com-money;
me=me+money;}
}
}
else if(u!=i)
{
if(com!=i)
printf(ai와 당신모두져서 %d원+400원만큼 잃습니다. \n, money);
else
{
printf(졌습니다(-%d원).\n, money);
me=me-money;
if(com==i)
com=com+money;
}
}
}while(comoney=0 || me=0);
if(comoney=0)
{
printf(당신이 이겼습니다!\n);
count++;
}
if(me=0)
{
  /printf(당신이 졌습니다.\n);
return 0;
}
}
//////////////////////////////////////////////////////////////////////
if(ops==2)
{
me=7000;
comoney=4500;
printf(점당 얼마를걸지 입력하세요.);
scanf(%d, &money);
printf(당신: 7000/ai: 4500을 가지고 점당 %d만큼 걸고시작합니다.\n, money);
do
{
i=rand()%2;
com=rand()%2;
printf(1또는0을 입력하세요.\n);
scanf(%d, &u);
if(u==i)
{
if(com==i)
printf(비겼습니다.\n);
else
{
printf(이겼습니다(+%d원)!\n, money);
if(com!=i){
com=com-money;
me=me+money;}
}
}
else if(u!=i)
{
if(com!=i)
printf(ai와 당신모두져서 %d원+400원만큼 잃습니다. \n, money);
else
{
printf(졌습니다(-%d원).\n, money);
me=me-money;
if(com==i)
com=com+money;
}
}
}while(comoney=0 || me=0);
if(comoney=0)
{
printf(당신이 이겼습니다!\n);
count++;
}
if(me=0)
{
printf(당신이 졌습니다.\n);
return 0;
}
}
if(ops==3)
{
me=5000;
comoney=5000;
printf(점당 얼마를걸지 입력하세요.);
scanf(%d, &money);
printf(당신: 5000/ai: 5000을 가지고 점당 %d만큼 걸고시작합니다.\n, money);
do
{
i=rand()%2;
com=rand()%2;
printf(1또는0을 입력하세요.\n);
scanf(%d, &u);
if(u==i)
{
if(com==i)
printf(비겼습니다.\n);
else
{
printf(이겼습니다(+%d원)!\n, money);
if(com!=i){
com=com-money;
me=me+money;}
}
}
else if(u!=i)
{
if(com!=i)
printf(ai와 당신모두져서 %d원+400원만큼 잃습니다. \n, money);
else
{
printf(졌습니다(-%d원).\n, money);
me=me-money;
if(com==i)
com=com+money;
}
}
}while(comoney=0 || me=0);
if(comoney=0)
{
printf(당신이 이겼습니다!\n);
count++;
}
if(me=0)
{
printf(당신이 졌습니다.\n);
return 0;
}
}
if(ops==4)
{
me=3000;
comoney=7000;
printf(점당 얼마를걸지 입력하세요.);
scanf(%d, &money);
printf(당신: 3000/ai: 7000을 가지고 점당 %d만큼 걸고시작합니다.\n, money);
do
{
i=rand()%2;
com=rand()%2;
printf(1또는0을 입력하세요.\n);
scanf(%d, &u);
if(u==i)
{
if(com==i)
printf(비겼습니다.\n);
else
{
printf(이겼습니다(+%d원)!\n, money);
if(com!=i){
com=com-money;
me=me+money;}
}
}
else if(u!=i)
{
if(com!=i)
printf(ai와 당신모두져서 %d원+400원만큼 잃습니다. \n, money);
else
{
printf(졌습니다(-%d원).\n, money);
me=me-money;
if(com==i)
com=com+money;
}
}
}while(comoney=0 || me=0);
if(comoney=0)
{
printf(당신이 이겼습니다!\n);
count++;
}
if(me=0)
{
printf(당신이 졌습니다.\n);
return 0;
}
}
if(ops==5)
{
me=1000;
comoney=9000;
printf(점당 얼마를걸지 입력하세요.);
scanf(%d, &money);
printf(당신: 1000/ai: 9000을 가지고 점당 %d만큼 걸고시작합니다.\n, money);
do
{
i=rand()%2;
com=rand()%2;
printf(1또는0을 입력하세요.\n);
scanf(%d, &u);
if(u==i)
{
if(com==i)
printf(비겼습니다.\n);
else
{
printf(이겼습니다(+%d원)!\n, money);
if(com!=i){
com=com-money;
me=me+money;}
}
}
else if(u!=i)
{
if(com!=i)
printf(ai와 당신모두져서 %d원+400원만큼 잃습니다. \n, money);
else
{
printf(졌습니다(-%d원).\n, money);
me=me-money;
if(com==i)
com=com+money;
}
}
}while(comoney=0 || me=0);
if(comoney=0)
{
printf(당신이 이겼습니다!\n);
count++;
}
if(me=0)
{
printf(당신이 졌습니다.\n);
return 0;
}
}
if(ops==6)
{
me=1000;
comoney=10000;
printf(점당 얼마를걸지 입력하세요.);
scanf(%d, &money);
printf(당신: 1000/ai: 10000을 가지고 점당 %d만큼 걸고시작합니다.\n, money);
do
{
i=rand()%2;
com=rand()%2;
printf(1또는0을 입력하세요.\n);
scanf(%d, &u);
if(u==i)
{
if(com==i)
printf(비겼습니다.\n);
else
{
printf(이겼습니다(+%d원)!\n, money);
if(com!=i){
com=com-money;
&;me=me+money;}
}
}
else if(u!=i)
{
if(com!=i)
printf(ai와 당신모두져서 %d원+400원만큼 잃습니다. \n, money);
else
{
printf(졌습니다(-%d원).\n, money);
me=me-money;
if(com==i)
com=com+money;
}
}
}while(comoney=0 || me=0);
if(comoney=0)
{
printf(당신이 이겼습니다!\n);
count++;
}
if(me=0)
{
printf(당신이 졌습니다.\n);
return 0;
}
}
if(ops==7)
{
printf(프로그램을 종료합니다.\n);
return 0;
}
}
}
너무 두서없이썻나...?
제가 초보라 그렇게 깔끔하게짜지는못해도
대강 이런내용입니다
ai와 내가돈을 들고시작하고 1,0을 선택해서 맞춘만큼 돈을 잃고 얻어서
0이될때까지 while문이 돌아가는건데,
0이될때까지돌아가는게 아니라 그냥 한번돌고 끝나버리네요... 왜그런지 알수있을까요?
-
터전
아 그리고 모드가해제되는건 일단신경쓰지말아주세요