#include <iostream>
#include <string>
#include <random>
#include <algorithm>
std::string generateRandomCode(int length = 8) {
const std::string characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
std::random_device rd;
std::mt19937 generator(rd());
std::uniform_int_distribution<> distribution(0, characters.size() - 1);
std::string code;
for (int i = 0; i < length; ++i) {
code += characters[distribution(generator)];
}
return code;
}
int main() {
std::string username;
std::cout << "กรุณาใส่ชื่อผู้ใช้: ";
std::getline(std::cin, username);
std::string code = generateRandomCode();
std::cout << "ยินดีต้อนรับ " << username << "!" << std::endl;
std::cout << "รหัสของคุณคือ: " << code << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8cmFuZG9tPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKc3RkOjpzdHJpbmcgZ2VuZXJhdGVSYW5kb21Db2RlKGludCBsZW5ndGggPSA4KSB7CiAgICBjb25zdCBzdGQ6OnN0cmluZyBjaGFyYWN0ZXJzID0gIjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IjsKICAgIHN0ZDo6cmFuZG9tX2RldmljZSByZDsKICAgIHN0ZDo6bXQxOTkzNyBnZW5lcmF0b3IocmQoKSk7CiAgICBzdGQ6OnVuaWZvcm1faW50X2Rpc3RyaWJ1dGlvbjw+IGRpc3RyaWJ1dGlvbigwLCBjaGFyYWN0ZXJzLnNpemUoKSAtIDEpOwoKICAgIHN0ZDo6c3RyaW5nIGNvZGU7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IGxlbmd0aDsgKytpKSB7CiAgICAgICAgY29kZSArPSBjaGFyYWN0ZXJzW2Rpc3RyaWJ1dGlvbihnZW5lcmF0b3IpXTsKICAgIH0KICAgIHJldHVybiBjb2RlOwp9CgppbnQgbWFpbigpIHsKICAgIHN0ZDo6c3RyaW5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