Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- #include <stdlib.h>
- using namespace std;
- int mas1 [4];
- int mas2 [4];
- static int sproba = 0;
- int RandNumber()
- {
- for (int i = 0; i < 4; i++)
- {
- (mas1[i] = 1 + rand() % 8);
- }
- }
- int digits(int n)
- {
- for (int i = 3; i >= 0; i--)
- {
- (mas2[i] = 1 + rand() % 8);
- }
- }
- void Count(int x, int y, int n, int bull, int cow)
- {
- int bulls = 0;
- int cows = 0;
- for (int i = 0; i < n; i++)
- if ((x + i) == (y + i))
- (bull)++;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++)
- if (((x + i) == (y + j)) && (i != j))
- (cow)++;
- }
- void game()
- {
- cout << "Input your number: ";
- int number;
- cin >> number;
- int b = digits(number);
- int bull, cow;
- cout << "Bulls = " << bull << ", cows = " << cow << endl;
- sproba++;
- if (bull == 4)
- {
- cout << "OK!\n";
- }
- else game();
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int m = 0;
- srand(time(0));
- int a = RandNumber();
- game();
- cout << "Выиграл " << m ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement