Advertisement
Guest User

Tìm Số Bí Ẩn Cải Tiến Fix

a guest
Mar 24th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 14.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7.     int MAX, Player, PlayerTim, PlayerTimA, PlayerTimB, Capdo, i;
  8.     int soBimatA, soBimatB, soBimatC, tieptucGamerPlayer, tieptucGame;
  9.     const int MIN = 1;
  10.     srand(time(NULL));
  11.  
  12.     printf("===============================\n");
  13.     printf("===========BE ~ TUYEN==========\n");
  14.     printf("====TRO CHOI: TIM SO BI MAT====\n");
  15.     printf("===============================\n");
  16.     ChonLai:
  17.     printf("==========LUA CHON MODE========\n");
  18.     printf("1. 1 Nguoi choi\n");
  19.     printf("2. 2 Nguoi choi\n");
  20.     printf("========LUA CHON CAP DO========\n");
  21.     printf("1. Tu 1 den 100\n");
  22.     printf("2. Tu 1 den 1000\n");
  23.     printf("3. Tu 1 den 10000\n");
  24.     ChonLaiMode:
  25.     printf("MOI BAN CHON MODE: ");
  26.     scanf("%d", &Player);
  27.     printf("MOI BAN CHON CAP DO: ");
  28.     scanf("%d", &Capdo);
  29.  
  30.     switch (Player) //Hiển thị thông tin khi Player chọn chế độ 1 hoặc 2 người chơi
  31.     {
  32.         case 1:
  33.             printf("\nBan chon che do 1 nguoi choi");
  34.         break;
  35.         case 2:
  36.             printf("\nBan chon che do 2 nguoi choi");
  37.         break;
  38.         default:
  39.             printf("\nBan khong the chon che do khac ! Vui long chon lai\n");
  40.             goto ChonLaiMode;
  41.         break;
  42.     }
  43.  
  44.     switch (Capdo) //Hiển thị thông tin khi Player chọn cấp độ chơi
  45.     {
  46.         case 1:
  47.             printf("\nBan chon cap do 1 | tu 1 den 100\n");
  48.         break;
  49.         case 2:
  50.             printf("\nBan chon cap do 1 | tu 1 den 1000\n");
  51.         break;
  52.         case 3:
  53.             printf("\nBan chon cap do 1 | tu 1 den 10000\n");
  54.         break;
  55.         default:
  56.             printf("\nBan khong the chon cap do khac ! Vui long chon lai\n");
  57.             goto ChonLaiMode;
  58.         break;
  59.     }
  60.  
  61.     if (Player == 1) // Chế độ dành cho 1 người chơi
  62.     {
  63.         if (Capdo == 1)
  64.         {
  65.             MAX = 100;
  66.             i = 1;
  67.             soBimatA = (rand() % (MAX - MIN + 1) + MIN);
  68.             do
  69.             {
  70.                 printf("So can tim la bao nhieu: ");
  71.                 scanf("%d", &PlayerTim);
  72.                 if (soBimatA > PlayerTim)
  73.                 {
  74.                     printf("Lon Hon !\n");
  75.                 }
  76.                 else if (soBimatA < PlayerTim)
  77.                 {
  78.                     printf("Nho Hon !\n");
  79.                 }
  80.                 else
  81.                 {
  82.                     printf("Chuc mung ! Be Tuyen da tim dung con so Bi Mat roi - %d lan\n", i);
  83.                 }
  84.                 i++;
  85.             }
  86.             while (soBimatA != PlayerTim);
  87.             printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
  88.             scanf("%d", &tieptucGamerPlayer);
  89.             if (tieptucGamerPlayer)
  90.             {
  91.                 goto ChonLai;
  92.             }
  93.         }
  94.         else if (Capdo == 2)
  95.         {
  96.             MAX = 1000;
  97.             i = 1;
  98.             soBimatB = (rand() % (MAX - MIN + 1) + MIN);
  99.             do
  100.             {
  101.                 printf("So can tim la bao nhieu: ");
  102.                 scanf("%d", &PlayerTim);
  103.                 if (soBimatB > PlayerTim)
  104.                 {
  105.                     printf("Lon Hon !\n");
  106.                 }
  107.                 else if (soBimatB < PlayerTim)
  108.                 {
  109.                     printf("Nho Hon !\n");
  110.                 }
  111.                 else
  112.                 {
  113.                     printf("Chuc mung ! Be Tuyen da tim dung con so Bi Mat roi - %d lan\n", i);
  114.                 }
  115.                 i++;
  116.             }
  117.             while (soBimatB != PlayerTim);
  118.             printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
  119.             scanf("%d", &tieptucGamerPlayer);
  120.             if (tieptucGamerPlayer)
  121.             {
  122.                 goto ChonLai;
  123.             }
  124.         }
  125.         else if (Capdo == 3)
  126.         {
  127.             MAX = 10000;
  128.             i = 1;
  129.             soBimatC = (rand() % (MAX - MIN + 1) + MIN);
  130.             do
  131.             {
  132.                 printf("So can tim la bao nhieu: ");
  133.                 scanf("%d", &PlayerTim);
  134.                 if (soBimatC > PlayerTim)
  135.                 {
  136.                     printf("Lon Hon !\n");
  137.                 }
  138.                 else if (soBimatC < PlayerTim)
  139.                 {
  140.                     printf("Nho Hon !\n");
  141.                 }
  142.                 else
  143.                 {
  144.                     printf("Chuc mung ! Be Tuyen da tim dung con so Bi Mat roi - %d lan\n", i);
  145.                 }
  146.                 i++;
  147.             }
  148.             while (soBimatC != PlayerTim);
  149.             printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
  150.             scanf("%d", &tieptucGamerPlayer);
  151.             if (tieptucGamerPlayer)
  152.             {
  153.                 goto ChonLai;
  154.             }
  155.         }
  156.     }
  157.     else
  158.     {
  159.         if (Capdo == 1)
  160.         {
  161.             MAX = 100;
  162.             i = 1;
  163.             soBimatA = (rand() % (MAX - MIN + 1) + MIN);
  164.             do
  165.             {
  166.                 printf("|Player A |So can tim la bao nhieu: ");
  167.                 scanf("%d", &PlayerTimA);
  168.                 printf("|Player B |So can tim la bao nhieu: ");
  169.                 scanf("%d", &PlayerTimB);
  170.                 if (soBimatA > PlayerTimA && soBimatA > PlayerTimB)
  171.                 {
  172.                     printf("|Player A | Lon Hon !\n|Player B | Lon Hon !\n");
  173.                 }
  174.                 else if (soBimatA < PlayerTimA && soBimatA < PlayerTimB)
  175.                 {
  176.                     printf("|Player A | Nho Hon !\n|Player B | Nho Hon !\n");
  177.                 }
  178.                 else if (soBimatA > PlayerTimA && soBimatA < PlayerTimB)
  179.                 {
  180.                     printf("|Player A | Lon Hon !\n|Player B | Nho Hon !\n");
  181.                 }
  182.                 else if (soBimatA > PlayerTimB && soBimatA < PlayerTimA)
  183.                 {
  184.                     printf("|Player A | Nho Hon !\n|Player B | Lon Hon !\n");
  185.                 }
  186.                 else if (soBimatA == PlayerTimA && soBimatA == PlayerTimB)
  187.                 {
  188.                     printf("Chuc mung ! Player A da tim duoc So Bi An\nChuc mung ! Player B da tim duoc So Bi An\n");
  189.                     printf("Tong cong: %d lan doan\n", i);
  190.                     goto HoiTiepTucA;
  191.  
  192.                 }
  193.                 else if (soBimatA == PlayerTimA && soBimatA != PlayerTimB)
  194.                 {
  195.                     printf("Chuc mung ! Player A da tim duoc So Bi An\n");
  196.                     printf("Huhu Player B thua roi roi =.=\n");
  197.                     printf("Tong cong: %d lan doan\n", i);
  198.                     goto HoiTiepTucA;
  199.                 }
  200.                 else if (soBimatA != PlayerTimA && soBimatA == PlayerTimB)
  201.                 {
  202.                     printf("Chuc mung ! Player B da tim duoc So Bi An\n");
  203.                     printf("Huhu Player A thua roi roi =.=\n");
  204.                     printf("Tong cong: %d lan doan\n", i);
  205.                             goto HoiTiepTucA;
  206.                 }
  207.                 else if (soBimatA == PlayerTimA && soBimatA > PlayerTimB)
  208.                 {
  209.                     printf("Chuc mung ! Player A da tim duoc So Bi An\n");
  210.                     printf("Huhu Player B thua roi roi =.=\n");
  211.                     printf("Tong cong: %d lan doan\n", i);
  212.                     goto HoiTiepTucA;
  213.                 }
  214.                 else if (soBimatA > PlayerTimA && soBimatA == PlayerTimB)
  215.                 {
  216.                     printf("Chuc mung ! Player B da tim duoc So Bi An\n");
  217.                     printf("Huhu Player A thua roi roi =.=\n");
  218.                     printf("Tong cong: %d lan doan\n", i);
  219.                     goto HoiTiepTucA;
  220.                 }
  221.                 i++;
  222.  
  223.             }
  224.             while (soBimatA != PlayerTimA && soBimatA != PlayerTimB);
  225.             HoiTiepTucA:
  226.             printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
  227.             scanf("%d", &tieptucGamerPlayer);
  228.             if (tieptucGamerPlayer)
  229.             {
  230.                 goto ChonLai;
  231.             }
  232.         }
  233.         if (Capdo == 2)
  234.         {
  235.             MAX = 1000;
  236.             i = 1;
  237.             soBimatB = (rand() % (MAX - MIN + 1) + MIN);
  238.             do
  239.             {
  240.                 printf("|Player A |So can tim la bao nhieu: ");
  241.                 scanf("%d", &PlayerTimA);
  242.                 printf("|Player B |So can tim la bao nhieu: ");
  243.                 scanf("%d", &PlayerTimB);
  244.                 if (soBimatB > PlayerTimA && soBimatB > PlayerTimB)
  245.                 {
  246.                     printf("|Player A | Lon Hon !\n|Player B | Lon Hon !\n");
  247.                 }
  248.                 else if (soBimatB < PlayerTimA && soBimatB < PlayerTimB)
  249.                 {
  250.                     printf("|Player A | Nho Hon !\n|Player B | Nho Hon !\n");
  251.                 }
  252.                 else if (soBimatB > PlayerTimA && soBimatB < PlayerTimB)
  253.                 {
  254.                     printf("|Player A | Lon Hon !\n|Player B | Nho Hon !\n");
  255.                 }
  256.                 else if (soBimatB > PlayerTimB && soBimatB < PlayerTimA)
  257.                 {
  258.                     printf("|Player A | Nho Hon !\n|Player B | Lon Hon !\n");
  259.                 }
  260.                 else if (soBimatB == PlayerTimA && soBimatB == PlayerTimB)
  261.                 {
  262.                     printf("Chuc mung ! Player A da tim duoc So Bi An\nChuc mung ! Player B da tim duoc So Bi An\n");
  263.                     printf("Tong cong: %d lan doan\n", i);
  264.                     goto HoiTiepTucB;
  265.  
  266.                 }
  267.                 else if (soBimatB == PlayerTimA && soBimatB != PlayerTimB)
  268.                 {
  269.                     printf("Chuc mung ! Player A da tim duoc So Bi An\n");
  270.                     printf("Huhu Player B thua roi roi =.=\n");
  271.                     printf("Tong cong: %d lan doan\n", i);
  272.                     goto HoiTiepTucB;
  273.                 }
  274.                 else if (soBimatB != PlayerTimA && soBimatB == PlayerTimB)
  275.                 {
  276.                     printf("Chuc mung ! Player B da tim duoc So Bi An\n");
  277.                     printf("Huhu Player A thua roi roi =.=\n");
  278.                     printf("Tong cong: %d lan doan\n", i);
  279.                     goto HoiTiepTucB;
  280.                 }
  281.                 else if (soBimatB == PlayerTimA && soBimatB > PlayerTimB)
  282.                 {
  283.                     printf("Chuc mung ! Player A da tim duoc So Bi An\n");
  284.                     printf("Huhu Player B thua roi roi =.=\n");
  285.                     printf("Tong cong: %d lan doan\n", i);
  286.                     goto HoiTiepTucB;
  287.                 }
  288.                 else if (soBimatB > PlayerTimA && soBimatB == PlayerTimB)
  289.                 {
  290.                     printf("Chuc mung ! Player B da tim duoc So Bi An\n");
  291.                     printf("Huhu Player A thua roi roi =.=\n");
  292.                     printf("Tong cong: %d lan doan\n", i);
  293.                     goto HoiTiepTucB;
  294.                 }
  295.                 i++;
  296.  
  297.             }
  298.             while (soBimatB != PlayerTimA && soBimatB != PlayerTimB);
  299.             HoiTiepTucB:
  300.             printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
  301.             scanf("%d", &tieptucGamerPlayer);
  302.             if (tieptucGamerPlayer)
  303.             {
  304.                 goto ChonLai;
  305.             }
  306.         }
  307.         if (Capdo == 1)
  308.         {
  309.             MAX = 10000;
  310.             i = 1;
  311.             soBimatC = (rand() % (MAX - MIN + 1) + MIN);
  312.             printf("SO BI MAT: %d\n", soBimatC);
  313.             do
  314.             {
  315.                 printf("|Player A |So can tim la bao nhieu: ");
  316.                 scanf("%d", &PlayerTimA);
  317.                 printf("|Player B |So can tim la bao nhieu: ");
  318.                 scanf("%d", &PlayerTimB);
  319.                 if (soBimatC > PlayerTimA && soBimatC > PlayerTimB)
  320.                 {
  321.                     printf("|Player A | Lon Hon !\n|Player B | Lon Hon !\n");
  322.                 }
  323.                 else if (soBimatC < PlayerTimA && soBimatC < PlayerTimB)
  324.                 {
  325.                     printf("|Player A | Nho Hon !\n|Player B | Nho Hon !\n");
  326.                 }
  327.                 else if (soBimatC > PlayerTimA && soBimatC < PlayerTimB)
  328.                 {
  329.                     printf("|Player A | Lon Hon !\n|Player B | Nho Hon !\n");
  330.                 }
  331.                 else if (soBimatC > PlayerTimB && soBimatC < PlayerTimA)
  332.                 {
  333.                     printf("|Player A | Nho Hon !\n|Player B | Lon Hon !\n");
  334.                 }
  335.                 else if (soBimatC == PlayerTimA && soBimatC == PlayerTimB)
  336.                 {
  337.                     printf("Chuc mung ! Player A da tim duoc So Bi An\nChuc mung ! Player B da tim duoc So Bi An\n");
  338.                     printf("Tong cong: %d lan doan\n", i);
  339.                     goto HoiTiepTucC;
  340.  
  341.                 }
  342.                 else if (soBimatC == PlayerTimA && soBimatC != PlayerTimB)
  343.                 {
  344.                     printf("Chuc mung ! Player A da tim duoc So Bi An\n");
  345.                     printf("Huhu Player B thua roi roi =.=\n");
  346.                     printf("Tong cong: %d lan doan\n", i);
  347.                     goto HoiTiepTucC;
  348.                 }
  349.                 else if (soBimatC != PlayerTimA && soBimatC == PlayerTimB)
  350.                 {
  351.                     printf("Chuc mung ! Player B da tim duoc So Bi An\n");
  352.                     printf("Huhu Player A thua roi roi =.=\n");
  353.                     printf("Tong cong: %d lan doan\n", i);
  354.                             goto HoiTiepTucC;
  355.                 }
  356.                 else if (soBimatC == PlayerTimA && soBimatC > PlayerTimB)
  357.                 {
  358.                     printf("Chuc mung ! Player A da tim duoc So Bi An\n");
  359.                     printf("Huhu Player B thua roi roi =.=\n");
  360.                     printf("Tong cong: %d lan doan\n", i);
  361.                     goto HoiTiepTucC;
  362.                 }
  363.                 else if (soBimatC > PlayerTimA && soBimatC == PlayerTimB)
  364.                 {
  365.                     printf("Chuc mung ! Player B da tim duoc So Bi An\n");
  366.                     printf("Huhu Player A thua roi roi =.=\n");
  367.                     printf("Tong cong: %d lan doan\n", i);
  368.                     goto HoiTiepTucC;
  369.                 }
  370.                 i++;
  371.  
  372.             }
  373.             while (soBimatC != PlayerTimA && soBimatC != PlayerTimB);
  374.             HoiTiepTucC:
  375.             printf("Ban co muon choi tiep khong? | 1. Co | 0. Khong: ");
  376.             scanf("%d", &tieptucGamerPlayer);
  377.             if (tieptucGamerPlayer)
  378.             {
  379.                 goto ChonLai;
  380.             }
  381.         }
  382.     }
  383.     return 0;
  384.  
  385. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement