Skip to content

Commit 4609106

Browse files
Add files via upload
1 parent 309333c commit 4609106

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

bt07/bai1.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int xucSac()
4+
{
5+
int n;
6+
n=rand()%6+1;
7+
return n;
8+
}
9+
int main()
10+
{
11+
srand(time(0));
12+
int n;
13+
int n1, n2;
14+
int diemP1=0, diemP2=0;
15+
while(diemP1<100 && diemP2<100)
16+
{
17+
if(diemP1<=diemP2)
18+
{
19+
n1=xucSac();
20+
diemP1+=n1;
21+
if(diemP1>100) diemP1-=n1;
22+
cout << "xuc xac nguoi choi 1: "<< n1 << " " << "Tong nguoi 1: "<< diemP1 <<endl;
23+
}
24+
else
25+
{
26+
n2=xucSac();
27+
diemP2+=n2;
28+
if(diemP2>100) diemP2-=n2;
29+
cout << "xuc xac nguoi choi 2: "<< n2 << " " << "Tong nguoi 2: "<< diemP2 <<endl;
30+
}
31+
}
32+
}

bt07/bai2.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
int ngauNhien()
4+
{
5+
int n;
6+
n=rand()%10+1;
7+
return n;
8+
}
9+
int main()
10+
{
11+
srand(time(0));
12+
int rua, tho;
13+
int so1, so2;
14+
while(rua<70 && tho <70)
15+
{
16+
so1=ngauNhien();
17+
if(so1>=1 && so1<=5) {rua+=3; cout << "Rua tien dai: " <<rua<<endl;}
18+
else if(so1<=8) {rua+=1; cout <<"Rua tien ngan: "<<rua<<endl;}
19+
else {rua-=6; cout <<"Rua truot: "<<rua<<endl;}
20+
if(rua<0) {rua=0; cout << "Do rua<0 -> ve vach xuat phat!"<<endl;}
21+
22+
so2=ngauNhien();
23+
if(so2>=1&&so2<=2) cout<<"Tho ngu: "<< tho << endl;
24+
else if(so2<=4) {tho+=9; cout <<"Tho tien dai: "<<tho<<endl;}
25+
else if(so2==5) {tho-=12; cout <<"Tho truot dai: "<<tho<<endl;}
26+
else if(so2<=8) {tho+=1; cout << "Tho tien ngan: "<<tho<<endl;}
27+
else {tho-=2; cout<<"Tho truot ngan: "<<tho<<endl;}
28+
if(tho<0) {tho=0; cout << "Do rua>70 -> ve vach xuat phat!"<<endl;}
29+
cout<< endl;
30+
}
31+
if(tho >= 70) cout<< "Tho win!";
32+
else if(rua >= 70) cout<<"Rua win!";
33+
}

0 commit comments

Comments
 (0)