Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<Windows.h>
- #include<time.h>
- using namespace std;
- int main()
- {
- int AI, player;
- //random ngau nhien 1 so tu 0 toi 2
- srand(time(NULL));
- AI = rand() % 3;
- cout << "0: Bua\n";
- cout << "1: Keo\n";
- cout << "2: Bao\n";
- cout << "Nhap dap an ban muon chon: ";
- cin >> player;
- //xuat ket qua may chon
- switch (AI)
- {
- case 0:cout << "May ra Bua"; break;
- case 1:cout << "May ra Keo"; break;
- case 2:cout << "May ra Bao"; break;
- }
- cout << endl;
- //xuat ket qua nguoi choi chon
- switch (player)
- {
- case 0:cout << "Ban ra Bua"; break;
- case 1:cout << "Ban ra Keo"; break;
- case 2:cout << "Ban ra Bao"; break;
- }
- cout << endl;
- //tinh toan nguoi hay may win
- if (player == AI)
- cout << "Hoa nhau";
- else if ((player == 0 && AI == 1) || (player == 1 && AI == 2) || (player == 2 && AI == 0))
- cout << "Ban thang";
- else
- cout << "May Thang";
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement