diff --git a/rand/main.cpp b/rand/main.cpp new file mode 100644 index 0000000..85299d7 --- /dev/null +++ b/rand/main.cpp @@ -0,0 +1,38 @@ +#include +#include +#include + +using namespace std; + +int main() { + srand(time(0)); + int LosowaLiczba = rand() % 10 + 1; + char que; + + cout << "Zgadnij liczbe od 1 do 10:" << endl; + int ZgadnijLiczba; + cin >> ZgadnijLiczba; + if (ZgadnijLiczba > 10) { + cout << "Podano liczbe spoza zakresu (1-10)." << endl; + return main(); + } + + if(ZgadnijLiczba == LosowaLiczba) { + cout << "Brawo! Zgadles liczbe!" << endl; + } + else { + cout << "Niestety, nie udalo Ci sie zgadnac. Zgadywana liczba byla: " << LosowaLiczba << endl; + cout << "Probuj jeszcze raz? (t/n)" << endl; + cin >> que; + if(que == 't') { + system("cls"); // czyszczenie ekranu dla nowej gry + main(); + } + else { + cout << "Do widzenia!" << endl; + } + } + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/rand/main.exe b/rand/main.exe new file mode 100644 index 0000000..606fc14 Binary files /dev/null and b/rand/main.exe differ diff --git a/rand/rand_6/main.cpp b/rand/rand_6/main.cpp new file mode 100644 index 0000000..d8285fd --- /dev/null +++ b/rand/rand_6/main.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +using namespace std; + +int main() { + int LosowaLiczby = 6; + int LosoweLiczby[LosowaLiczby]; + srand(time(0)); + for (int i = 0; i < LosowaLiczby; i++) { + LosoweLiczby[i] = rand() % 10 + 1; + for (int j = 0; j < i; j++) { + if (LosoweLiczby[i] == LosoweLiczby[j]) { + i--; + break; + } + } + } + cout << "Losowe liczby: "; + for (int i = 0; i < LosowaLiczby; i++) { + cout << LosoweLiczby[i] << " "; + } + cout << endl; + + system("pause"); + return 0; +} \ No newline at end of file diff --git a/rand/rand_6/main.exe b/rand/rand_6/main.exe new file mode 100644 index 0000000..4e10832 Binary files /dev/null and b/rand/rand_6/main.exe differ