Created
May 7, 2025 12:36
-
-
Save fantom44ik/eef8bb06ab9888bc1f81fec36161b466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
srand(time(0)); | |
setlocale(0, ""); | |
// 1st | |
/*const int SIZE = 10; | |
int ar[SIZE]; | |
int sum = 0; | |
cout << "Массив: " << "\n"; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
ar[i] = rand() % 41 - 20; | |
cout << ar[i] << " "; | |
sum += ar[i]; | |
} | |
cout << "\n"; | |
int avarage = sum / SIZE; | |
cout << "Сумма элеменнтов: " << sum << "\n"; | |
cout << "Среднее арифметическое: " << avarage << "\n";*/ | |
// 2nd | |
/*const int SIZE = 100; | |
int ar[SIZE]; | |
int sum = 0; | |
int guess; | |
cout << "Введите число: "; | |
cin >> guess; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
ar[i] = rand() % guess + 1; | |
cout << ar[i] << " "; | |
if (ar[i] == guess) | |
sum++; | |
} | |
cout << "\n"; | |
cout << "Количество совпадений: " << sum << "\n";*/ | |
// 3rd | |
/*const int SIZE = 20; | |
int ar[SIZE]; | |
cout << "Массив: " << "\n"; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
ar[i] = rand() % 101 - 50; | |
cout << ar[i] << " "; | |
} | |
cout << "\n"; | |
int min = ar[0], max = ar[0]; | |
int minIndex = 0, maxIndex = 0; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
if (ar[i] < min) | |
{ | |
min = ar[i]; | |
minIndex = i; | |
} | |
else if (ar[i] > max) | |
{ | |
max = ar[i]; | |
maxIndex = i; | |
} | |
} | |
cout << "Минимальный элемент: " << min << " Индекс: " << minIndex << "\n"; | |
cout << "Максимальный элемент: " << max << " Индекс: " << maxIndex << "\n";*/ | |
// 4th | |
/*const int SIZE = 200; | |
int ar[SIZE]; | |
int singleDigit = 0, doubleDigit = 0, tripleDigit = 0; | |
for (int i = 0; i < SIZE; i++) { | |
ar[i] = rand() % 201; | |
cout << ar[i] << " "; | |
if (ar[i] < 10) | |
singleDigit++; | |
else if (ar[i] < 100) | |
doubleDigit++; | |
else | |
tripleDigit++; | |
} | |
cout << "\n"; | |
int singlePercent = (singleDigit * 100) / SIZE; | |
int doublePercent = (doubleDigit * 100) / SIZE; | |
int triplePercent = (tripleDigit * 100) / SIZE; | |
cout << "Процент однозначных чисел: " << singlePercent << "%\n"; | |
cout << "Процент двузначных чисел: " << doublePercent << "%\n"; | |
cout << "Процент трехзначных чисел: " << triplePercent << "%\n";*/ | |
// 6th | |
const int SIZE = 5; | |
int ar[SIZE]; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
ar[i] = rand() % 42 + 1; | |
} | |
int first_guess, second_guess, third_guess, fourth_guess, fifth_guess; | |
cout << "Введите 5 чисел от 1 до 42: "; | |
cin >> first_guess >> second_guess >> third_guess >> fourth_guess >> fifth_guess; | |
int guess[5] = { first_guess, second_guess, third_guess, fourth_guess, fifth_guess }; | |
int count = 0; | |
for (int i = 0; i < SIZE; i++) | |
{ | |
for (int j = 0; j < SIZE; j++) | |
{ | |
if (ar[i] == guess[j]) | |
{ | |
count++; | |
} | |
} | |
} | |
cout << "Ваши числа: " << first_guess << " " << second_guess << " " << third_guess << " " << fourth_guess << " " << fifth_guess << "\n"; | |
cout << "Совпадений: " << count << "\n"; | |
if (count == 5) | |
{ | |
cout << "Вы выиграли джекпот!\n"; | |
} | |
else if (count == 4) | |
{ | |
cout << "Вы выиграли 1000$!\n"; | |
} | |
else if (count == 3) | |
{ | |
cout << "Вы выиграли 100$!\n"; | |
} | |
else if (count == 2) | |
{ | |
cout << "Вы выиграли 10$!\n"; | |
} | |
else if (count == 1) | |
{ | |
cout << "Вы выиграли 1$!\n"; | |
} | |
else | |
{ | |
cout << "Вы ничего не выиграли.\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment