Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int main()
- {
- int MAX, Player, PlayerTim, PlayerTimA, PlayerTimB, Capdo, i;
- int soBimatA, soBimatB, soBimatC, tieptucGamerPlayer, tieptucGame;
- const int MIN = 1;
- srand(time(NULL));
- printf("===============================\n");
- printf("===========BE ~ TUYEN==========\n");
- printf("====TRO CHOI: TIM SO BI MAT====\n");
- printf("===============================\n");
- ChonLai:
- printf("==========LUA CHON MODE========\n");
- printf("1. 1 Nguoi choi\n");
- printf("2. 2 Nguoi choi\n");
- printf("========LUA CHON CAP DO========\n");
- printf("1. Tu 1 den 100\n");
- printf("2. Tu 1 den 1000\n");
- printf("3. Tu 1 den 10000\n");
- ChonLaiMode:
- printf("MOI BAN CHON MODE: ");
- scanf("%d", &Player);
- printf("MOI BAN CHON CAP DO: ");
- scanf("%d", &Capdo);
- switch (Player) //Hiển thị thông tin khi Player chọn chế độ 1 hoặc 2 người chơi
- {
- case 1:
- printf("\nBan chon che do 1 nguoi choi");
- break;
- case 2:
- printf("\nBan chon che do 2 nguoi choi");
- break;
- default:
- printf("\nBan khong the chon che do khac ! Vui long chon lai\n");
- goto ChonLaiMode;
- break;
- }
- switch (Capdo) //Hiển thị thông tin khi Player chọn cấp độ chơi
- {
- case 1:
- printf("\nBan chon cap do 1 | tu 1 den 100\n");
- break;
- case 2:
- printf("\nBan chon cap do 1 | tu 1 den 1000\n");
- break;
- case 3:
- printf("\nBan chon cap do 1 | tu 1 den 10000\n");
- break;
- default:
- printf("\nBan khong the chon cap do khac ! Vui long chon lai\n");
- goto ChonLaiMode;
- break;
- }
- if (Player == 1) // Chế độ dành cho 1 người chơi
- {
- if (Capdo == 1)
- {
- MAX = 100;
- i = 1;
- soBimatA = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- printf("So can tim la bao nhieu: ");
- scanf("%d", &PlayerTim);
- if (soBimatA > PlayerTim)
- {
- printf("Lon Hon !\n");
- }
- else if (soBimatA < PlayerTim)
- {
- printf("Nho Hon !\n");
- }
- else
- {
- printf("Chuc mung ! Be Tuyen da tim dung con so Bi Mat roi - %d lan\n", i);
- }
- i++;
- }
- while (soBimatA != PlayerTim);
- printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
- scanf("%d", &tieptucGamerPlayer);
- if (tieptucGamerPlayer)
- {
- goto ChonLai;
- }
- }
- else if (Capdo == 2)
- {
- MAX = 1000;
- i = 1;
- soBimatB = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- printf("So can tim la bao nhieu: ");
- scanf("%d", &PlayerTim);
- if (soBimatB > PlayerTim)
- {
- printf("Lon Hon !\n");
- }
- else if (soBimatB < PlayerTim)
- {
- printf("Nho Hon !\n");
- }
- else
- {
- printf("Chuc mung ! Be Tuyen da tim dung con so Bi Mat roi - %d lan\n", i);
- }
- i++;
- }
- while (soBimatB != PlayerTim);
- printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
- scanf("%d", &tieptucGamerPlayer);
- if (tieptucGamerPlayer)
- {
- goto ChonLai;
- }
- }
- else if (Capdo == 3)
- {
- MAX = 10000;
- i = 1;
- soBimatC = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- printf("So can tim la bao nhieu: ");
- scanf("%d", &PlayerTim);
- if (soBimatC > PlayerTim)
- {
- printf("Lon Hon !\n");
- }
- else if (soBimatC < PlayerTim)
- {
- printf("Nho Hon !\n");
- }
- else
- {
- printf("Chuc mung ! Be Tuyen da tim dung con so Bi Mat roi - %d lan\n", i);
- }
- i++;
- }
- while (soBimatC != PlayerTim);
- printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
- scanf("%d", &tieptucGamerPlayer);
- if (tieptucGamerPlayer)
- {
- goto ChonLai;
- }
- }
- }
- else
- {
- if (Capdo == 1)
- {
- MAX = 100;
- i = 1;
- soBimatA = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- printf("|Player A |So can tim la bao nhieu: ");
- scanf("%d", &PlayerTimA);
- printf("|Player B |So can tim la bao nhieu: ");
- scanf("%d", &PlayerTimB);
- if (soBimatA > PlayerTimA && soBimatA > PlayerTimB)
- {
- printf("|Player A | Lon Hon !\n|Player B | Lon Hon !\n");
- }
- else if (soBimatA < PlayerTimA && soBimatA < PlayerTimB)
- {
- printf("|Player A | Nho Hon !\n|Player B | Nho Hon !\n");
- }
- else if (soBimatA > PlayerTimA && soBimatA < PlayerTimB)
- {
- printf("|Player A | Lon Hon !\n|Player B | Nho Hon !\n");
- }
- else if (soBimatA > PlayerTimB && soBimatA < PlayerTimA)
- {
- printf("|Player A | Nho Hon !\n|Player B | Lon Hon !\n");
- }
- else if (soBimatA == PlayerTimA && soBimatA == PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\nChuc mung ! Player B da tim duoc So Bi An\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucA;
- }
- else if (soBimatA == PlayerTimA && soBimatA != PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\n");
- printf("Huhu Player B thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucA;
- }
- else if (soBimatA != PlayerTimA && soBimatA == PlayerTimB)
- {
- printf("Chuc mung ! Player B da tim duoc So Bi An\n");
- printf("Huhu Player A thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucA;
- }
- else if (soBimatA == PlayerTimA && soBimatA > PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\n");
- printf("Huhu Player B thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucA;
- }
- else if (soBimatA > PlayerTimA && soBimatA == PlayerTimB)
- {
- printf("Chuc mung ! Player B da tim duoc So Bi An\n");
- printf("Huhu Player A thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucA;
- }
- i++;
- }
- while (soBimatA != PlayerTimA && soBimatA != PlayerTimB);
- HoiTiepTucA:
- printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
- scanf("%d", &tieptucGamerPlayer);
- if (tieptucGamerPlayer)
- {
- goto ChonLai;
- }
- }
- if (Capdo == 2)
- {
- MAX = 1000;
- i = 1;
- soBimatB = (rand() % (MAX - MIN + 1) + MIN);
- do
- {
- printf("|Player A |So can tim la bao nhieu: ");
- scanf("%d", &PlayerTimA);
- printf("|Player B |So can tim la bao nhieu: ");
- scanf("%d", &PlayerTimB);
- if (soBimatB > PlayerTimA && soBimatB > PlayerTimB)
- {
- printf("|Player A | Lon Hon !\n|Player B | Lon Hon !\n");
- }
- else if (soBimatB < PlayerTimA && soBimatB < PlayerTimB)
- {
- printf("|Player A | Nho Hon !\n|Player B | Nho Hon !\n");
- }
- else if (soBimatB > PlayerTimA && soBimatB < PlayerTimB)
- {
- printf("|Player A | Lon Hon !\n|Player B | Nho Hon !\n");
- }
- else if (soBimatB > PlayerTimB && soBimatB < PlayerTimA)
- {
- printf("|Player A | Nho Hon !\n|Player B | Lon Hon !\n");
- }
- else if (soBimatB == PlayerTimA && soBimatB == PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\nChuc mung ! Player B da tim duoc So Bi An\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucB;
- }
- else if (soBimatB == PlayerTimA && soBimatB != PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\n");
- printf("Huhu Player B thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucB;
- }
- else if (soBimatB != PlayerTimA && soBimatB == PlayerTimB)
- {
- printf("Chuc mung ! Player B da tim duoc So Bi An\n");
- printf("Huhu Player A thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucB;
- }
- else if (soBimatB == PlayerTimA && soBimatB > PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\n");
- printf("Huhu Player B thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucB;
- }
- else if (soBimatB > PlayerTimA && soBimatB == PlayerTimB)
- {
- printf("Chuc mung ! Player B da tim duoc So Bi An\n");
- printf("Huhu Player A thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucB;
- }
- i++;
- }
- while (soBimatB != PlayerTimA && soBimatB != PlayerTimB);
- HoiTiepTucB:
- printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
- scanf("%d", &tieptucGamerPlayer);
- if (tieptucGamerPlayer)
- {
- goto ChonLai;
- }
- }
- if (Capdo == 1)
- {
- MAX = 10000;
- i = 1;
- soBimatC = (rand() % (MAX - MIN + 1) + MIN);
- printf("SO BI MAT: %d\n", soBimatC);
- do
- {
- printf("|Player A |So can tim la bao nhieu: ");
- scanf("%d", &PlayerTimA);
- printf("|Player B |So can tim la bao nhieu: ");
- scanf("%d", &PlayerTimB);
- if (soBimatC > PlayerTimA && soBimatC > PlayerTimB)
- {
- printf("|Player A | Lon Hon !\n|Player B | Lon Hon !\n");
- }
- else if (soBimatC < PlayerTimA && soBimatC < PlayerTimB)
- {
- printf("|Player A | Nho Hon !\n|Player B | Nho Hon !\n");
- }
- else if (soBimatC > PlayerTimA && soBimatC < PlayerTimB)
- {
- printf("|Player A | Lon Hon !\n|Player B | Nho Hon !\n");
- }
- else if (soBimatC > PlayerTimB && soBimatC < PlayerTimA)
- {
- printf("|Player A | Nho Hon !\n|Player B | Lon Hon !\n");
- }
- else if (soBimatC == PlayerTimA && soBimatC == PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\nChuc mung ! Player B da tim duoc So Bi An\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucC;
- }
- else if (soBimatC == PlayerTimA && soBimatC != PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\n");
- printf("Huhu Player B thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucC;
- }
- else if (soBimatC != PlayerTimA && soBimatC == PlayerTimB)
- {
- printf("Chuc mung ! Player B da tim duoc So Bi An\n");
- printf("Huhu Player A thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucC;
- }
- else if (soBimatC == PlayerTimA && soBimatC > PlayerTimB)
- {
- printf("Chuc mung ! Player A da tim duoc So Bi An\n");
- printf("Huhu Player B thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucC;
- }
- else if (soBimatC > PlayerTimA && soBimatC == PlayerTimB)
- {
- printf("Chuc mung ! Player B da tim duoc So Bi An\n");
- printf("Huhu Player A thua roi roi =.=\n");
- printf("Tong cong: %d lan doan\n", i);
- goto HoiTiepTucC;
- }
- i++;
- }
- while (soBimatC != PlayerTimA && soBimatC != PlayerTimB);
- HoiTiepTucC:
- printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
- scanf("%d", &tieptucGamerPlayer);
- if (tieptucGamerPlayer)
- {
- goto ChonLai;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement