Random | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 4

Random

How to create a code for deducing random letters.

22nd Jan 2018, 1:10 PM
Михаил Попов
Михаил Попов - avatar
3 Réponses
+ 7
const stand for constant, so that letters don't get switch while the program runs.
24th Jan 2018, 12:39 PM
Thor Westergren
Thor Westergren - avatar
+ 3
You can only get random integers, so it would look something like this: #include <iostream> #include <string> #include <ctime> #include <cstdlib> //I think this is header with rand & srand using namespace std; const string ch = “qwertyuiopasdfghjklzxcvbnm”; int main() { srand(time(0)); int a = rand() % 26; cout << ch[a]; return 0; }
22nd Jan 2018, 2:32 PM
Jacob Pembleton
Jacob Pembleton - avatar
0
What does const do? please tell me
22nd Jan 2018, 2:46 PM
Михаил Попов
Михаил Попов - avatar