MrComan
Onaylı Üye
C++ Program ismi sürekli olarak değiştirme bu konu hakkında yardım ederseniz sevinirim
string rastgele() {
string tmp_s;
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
srand( (unsigned) time(NULL) * getpid());
tmp_s.reserve(33);
for (int i = 0; i < len; ++i)
tmp_s += alphanum[rand() % (sizeof(alphanum) - 1)];
return tmp_s;
}
#include <cstdlib>
#include <ctime>
#include <string>
#include <windows.h>
#include <iostream>
int main()
{
int a;
srand(time(nullptr));//changes random seed
std::string title = "";
int n = 10;//title length
for (int i = 0; i < n; i++)
{
a = rand() % 2; //50% numbers and 50% letters
if (a == 0)
title += rand() % 26 + 'a';//generates letters
else
title += std::to_string(rand() % 10);//generates numbers
}
SetConsoleTitleA(title.c_str());
std::cout << "test" << std::endl;
system("PAUSE");
return 0;
}
eklemeyi unutmuşum, sağol broC++:#include <cstdlib> #include <ctime> #include <string> #include <windows.h> #include <iostream> int main() { int a; srand(time(nullptr));//changes random seed std::string title = ""; int n = 10;//title length for (int i = 0; i < n; i++) { a = rand() % 2; //50% numbers and 50% letters if (a == 0) title += rand() % 26 + 'a';//generates letters else title += std::to_string(rand() % 10);//generates numbers } SetConsoleTitleA(title.c_str()); std::cout << "test" << std::endl; system("PAUSE"); return 0; }
Kaynak :Bağlantıları görmek için lütfen Giriş Yap