0

How do you randomly print words to console???

23rd Jul 2017, 6:55 AM
smartguy100
smartguy100 - avatar
6 Antworten
+ 8
make a list/array of words use rand() to select a number between 0 and the number of words - 1 print the word
23rd Jul 2017, 7:02 AM
jay
jay - avatar
+ 8
Probably something like this crap, idk. :D https://code.sololearn.com/cSY5Ob4m8isM/?ref=app
23rd Jul 2017, 7:24 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
@Esenyi: you probs already know that time.h is a c header., ctime is the c++ header Not that it makes all that much difference though 😊
23rd Jul 2017, 7:17 AM
jay
jay - avatar
+ 4
#include <iostream> #include <cstdlib> #include <time.h> using namespace std; int main() { char word[10]; for (int i = 0; i < 10; i++ ) { for (int j = 0; j < 10; j++) { //assign word[j] with random number generator with a modulus of 26 and 65 added to its value } cout << word << endl; } return 0; }
23rd Jul 2017, 7:14 AM
LordGhostX
LordGhostX - avatar
23rd Jul 2017, 12:05 PM
LordGhostX
LordGhostX - avatar
+ 3
@Jay thanks for that didn't remember
23rd Jul 2017, 8:58 AM
LordGhostX
LordGhostX - avatar