Now, your question could be interpreted in a few ways. The ambiguity probably comes from a language difference.
A random vector for those four colours is best achieved via a shuffle algorithm.
I assume you want to return a vector with all four colours except in a different order.
If you're unfamiliar with the std::shuffle function ... don't quote me on that just - it's been a while... You could achieve something similar by randomly picking two elements and swapping their contents perhaps?
If your problem corresponds to iamthwee's interpretation, then his solution is appropriate.
If your problem is that you want to create a vector of arbitrary size where each element is one of the four color-strings, picked at random. Then, a simple solution is to map each color to a number and generate the numbers randomly (e.g. with rand() for a quick and easy solution). As so:
the output not as i expected. it just output the same colour..
i expect the output like this:
"red,yellow,green,blue" (those four colors are randomly shuffle for every attempt) :'( help me with this code. i want to build mastermind code.
APLX is a very complete implementation of the APL programming language from MicroAPL. The company stopped producing it in 2016 and it has been taken over by Dyalog. While Dyalog ...