Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. using namespace std;
  5.  
  6. int mas1 [4];
  7. int mas2 [4];
  8. static int sproba = 0;
  9.  
  10. int RandNumber()
  11. {
  12.     for (int i = 0; i < 4; i++)
  13.     {
  14.         (mas1[i] = 1 + rand() % 8);
  15.     }
  16. }
  17. int digits(int n)
  18. {
  19.     for (int i = 3; i >= 0; i--)
  20.     {
  21.         (mas2[i] = 1 + rand() % 8);
  22.     }
  23. }
  24. void Count(int x, int y, int n, int bull, int cow)
  25. {
  26.     int bulls = 0;
  27.     int cows = 0;
  28.  
  29.     for (int i = 0; i < n; i++)
  30.         if ((x + i) == (y + i))
  31.             (bull)++;
  32.     for (int i = 0; i < n; i++)
  33.         for (int j = 0; j < n; j++)
  34.             if (((x + i) == (y + j)) && (i != j))
  35.                 (cow)++;
  36. }
  37. void game()
  38. {
  39.     cout << "Input your number: ";
  40.     int number;
  41.     cin >> number;
  42.     int b = digits(number);
  43.     int bull, cow;
  44.     cout << "Bulls = " << bull << ", cows = " << cow << endl;
  45.     sproba++;
  46.     if (bull == 4)
  47.     {
  48.         cout << "OK!\n";
  49.     }
  50.     else game();
  51. }
  52. int main()
  53. {
  54.     setlocale(LC_ALL, "Russian");
  55.     int m = 0;
  56.     srand(time(0));
  57.     int a = RandNumber();
  58.     game();
  59.     cout << "Выиграл " << m ;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement