Skip to content

Instantly share code, notes, and snippets.

@lexuanquynh
Created October 22, 2024 08:33
Show Gist options
  • Save lexuanquynh/af122c965426406df81d4643c02617e4 to your computer and use it in GitHub Desktop.
Save lexuanquynh/af122c965426406df81d4643c02617e4 to your computer and use it in GitHub Desktop.
Lucky.cpp
#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