~cpp
내가 푼 방�(난잡한것 같�...ㅡㅡ;;)
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
void main()
{
double money=1000;
double beting;
int num;
int sq1,sq2;
while(money>=10)
{
cout << "ë‹¹ì‹ ì�˜ 재산ì�€ $" << money << " 입니다." << endl
<< "배팅하실 금액ì�„ ì �어주세요($10~$100) : $"; cin >> beting;
if(money<beting)
{
cout << "ë‹¹ì‹ ì�˜ 재산보다 많습니다. 다시 배팅해 주ì‹ì‹œì˜¤." <<endl;
continue;
}
if(beting >100 || beting <10)
{
cout << "$10~$100 사ì�´ë¡œ ìž…ë ¥í•´ 주ì‹ì‹œì˜¤." << endl;
continue;
}
money-=beting;
cout << "ë‹¹ì‹ ì�´ ë°°íŒ…í•˜ì‹ ê¸ˆì•¡ì�€ $" << beting <<" 입니다." << endl
<< "ì–´ë””ì—� ê±°ì‹œê² ìŠµë‹ˆê¹Œ?" << endl
<< "|----------------------------------|" <<endl
<< "| Number | 배팅 | 지불 |" <<endl
<< "|--------+------------+------------|" <<endl
<< "| 1 | 2 or 12 | 5:1 |" <<endl
<< "| 2 | 4 or 10 | 2.5:1 |" <<endl
<< "| 3 | 6 or 8 | 1.5:1 |" <<endl
<< "|----------------------------------|" <<endl
<<"배팅 하실 곳�? (1 ~ 3) : "; cin >> num;
while(num!=1 && num!=2 && num!=3)
{
cout << "1 ~ 3 범위 ë‚´ì—�서 ìž…ë ¥í•´ 주ì‹ì‹œì˜¤ : ";
cin >> num;
}
srand (time (NULL));
sq1 = rand()%6; sq1++;
sq2 = rand()%6; sq2++;
cout << num <<"번� �하셨습니다. 그럼 게임� 진행합니다." <<endl
<< "첫번째 주사위� 숫�는 :" << sq1 << endl
<< "�번째 주사위� 숫�는 :" << sq2 << endl
<< "� 주사위� 합� : " << sq1+sq2 <<endl;
if((sq1+sq2)%2==0)
{
switch(num)
{
case 1:
if((sq1+sq2)==2 || (sq1+sq2)==12)
{
beting*=5;
cout << "ë‹¹ì‹ ì�´ 승리하셨습니다." <<endl
<<"$" << money << " + "<<"$" <<beting<< " = $" << money+beting;
money+=beting;
}
else
{
cout << "ë‹¹ì‹ ì�´ 패배하셨습니다."<<endl;
}
break;
case 2:
if((sq1+sq2)==4 || (sq1+sq2)==10)
{
beting*=2.5;
cout << "ë‹¹ì‹ ì�´ 승리하셨습니다." <<endl
<<"$" << money << " + "<<"$" <<beting<< " = $" << money+beting;
money+=beting;
}
else
{
cout << "ë‹¹ì‹ ì�´ 패배하셨습니다."<<endl;
}
break;
case 3:
if((sq1+sq2)==6 || (sq1+sq2)==8)
{
beting*=1.5;
cout << "ë‹¹ì‹ ì�´ 승리하셨습니다." <<endl
<<"$" << money << " + "<<"$" <<beting<< " = $" << money+beting;
money+=beting;
}
else
{
cout <<"ë‹¹ì‹ ì�´ 패배하셨습니다."<<endl;
}
break;
default:
cout << "ë‹¹ì‹ ì�´ 패배하셨습니다."<<endl;
break;
}
}
else
cout <<"ë‹¹ì‹ ì�´ 패배하셨습니다." <<endl;
}
cout << "�� 모� 잃으셨습니다." <<endl;
}
아래 처럼 ì—ë§�í�¬ë¥¼ 걸어주면 ì–´ë””ë¡œë“ ë§�í�¬ê°€ ë�˜ì§€.--Leonardong










