Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "stdio.h"
- #include "math.h"
- #include "stdlib.h"
- #include "time.h"
- int main()
- {
- int liczba[6];
- int losowa[6];
- int wystepowanie[6];
- int min = 1;
- int max = 49;
- int L = max - min + 1;
- srand(time(NULL));
- printf("Podaj 6 liczb od 1 do 49\n");
- for (int i = 0; i <= 5; i++)
- {
- wystepowanie[i] = 0;
- }
- //WPROWADZAM LICZBY
- for (int i = 0; i <= 5; i++)
- {
- scanf("%d", &liczba[i]);
- }
- //GENERUJE LICZBY LOSOWE
- for (int i = 0; i <= 5; i++)
- {
- losowa[i] = rand() % L + min;
- }
- //SPRAWDZAM CZY WPROWADZONE LICZBY SĄ Z ZADANEGO PRZEDZIAŁU
- for (int i = 0; i <= 5; i++)
- {
- if (liczba[i] < 1 || liczba[i] > 49)
- {
- printf("Ktoras z zadanych liczb nie spelnia wymagan przedzialu");
- system("pause");
- }
- }
- for (int i = 0; i <= 5; i++)
- {
- for (int n = 0; n <= 5; n++)
- {
- if (liczba[i] == losowa[n])
- {
- wystepowanie[i]++;
- }
- }
- }
- printf("Liczby losowe w tym losowaniu to: ");
- for (int i = 0; i <= 5; i++)
- {
- printf("%d ", losowa[i]);
- }
- printf("\nLiczba %d powtarzala sie %d razy", liczba[1], wystepowanie[1]);
- system("pause");
- }
- /*int main()
- {
- int min = 1;
- int max = 49;
- int L = max - min + 1;
- int losowa[6];
- srand(time(NULL));
- for (int i = 0; i <= 5; i++)
- {
- losowa[i] = rand() % L + min;
- }
- for (int i = 0; i <= 5; i++)
- {
- printf("%d\n", losowa[1]);
- }
- system("pause");
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement