Hi Chay,
Can you figure out how to adapt
JLBorges code to do what you want? You have 2 things : push_back a char to a string; push_back the string to a vector.
When doing your own code, try to get the simple things working first, then add complexity afterwards - preferably in small amounts. In this case get the code to build 1 string of 7 numbers working first, then add code to do 5 lines of them.
For loops are good when the number of iterations is known. While loops are better when some end condition is satisfied - like if you had some sentinel value to end the input for example.
I know this sounds boring & I might have said it before, but try to write pseudo-code with comments first, then translate to actual code:
1 2 3 4
|
// loop 7 times:
// make a random number 1-9
// push_back number to string
//end loop.
|
Now add the extra complexity:
1 2 3 4 5 6 7 8 9
|
//loop 5 times:
//
// loop 7 times:
// make a random number 1-9
// push_back number to string
// end 7 times loop.
//
//push_back string into vector
//end 5 times loop
|
So code the first part, then it become easy to do the second part.
Hope this helps a bit.
Edit: I didn't see
JLBorges last post or Chay's replies. Just trying to get Chay to think about the process a bit. Any way probably better in JLB's expert hands.