#include <iostream>
#include <cstdlib>
#include <ctime>
#include <set>
using namespace std;
const int LICENSE_LENGTH = 10; // długość numeru licencji
const int NUM_LICENSES = 10; // liczba wygenerowanych numerów licencji
int main()
{
srand((unsigned int)time(NULL)); // inicjalizacja generatora liczb losowych
set<string> licenses; // zbiór przechowujący wygenerowane numery licencji
while (licenses.size() < NUM_LICENSES) {
// generowanie numeru licencji
string license;
for (int i = 0; i < LICENSE_LENGTH; i++) {
int rand_num = rand() % 36; // losowa liczba z zakresu 0-35 (36 liter i cyfr)
if (rand_num < 10) {
license += '0' + rand_num; // liczba
} else {
license += 'A' + (rand_num - 10); // litera
}
}
// dodanie numeru licencji do zbioru (jeśli nie istnieje już taki numer)
if (licenses.find(license) == licenses.end()) {
licenses.insert(license);
}
}
// wyświetlenie wygenerowanych numerów licencji
for (const auto& license : licenses) {
cout << license << endl;
}
return 0;
}
Napisałem program, który generuje numery licencji i zwraca on błąd 0xc0000005, dlaczego.