Created
October 22, 2024 08:33
-
-
Save lexuanquynh/af122c965426406df81d4643c02617e4 to your computer and use it in GitHub Desktop.
Lucky.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
using namespace std; | |
int main() { | |
int sotien = 1000; | |
int datcuoc; | |
int sode; | |
int soduocchon; | |
srand(static_cast<unsigned>(time(0))); | |
while(sotien > 0) { | |
do { | |
cout << "nhap so tien dat cuoc: "; | |
cin >> datcuoc; | |
} | |
while(datcuoc < 0 || datcuoc > sotien); | |
do { | |
cout << "hay nhap so ban chon: "; | |
cin >> soduocchon; | |
} | |
while(soduocchon < 0 || soduocchon > 9); | |
sode = rand() % 10; | |
cout << "so de hom nay ve la: " << sode << endl; | |
if(sode == soduocchon){ | |
sotien = sotien + datcuoc * 7; | |
cout << "chuc ban da trung thuong, so tien hien tai cua ban la: "<< sotien << endl; | |
}else { | |
sotien = sotien - datcuoc; | |
cout << "chuc ban may man lan sau, so tien con lai la: " << sotien << endl; | |
} | |
} | |
cout << "dung bao gio dinh vao co bac, nhung neu choi hay kiem den toi, thankiu:))" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment