This is my first post on these forums. I recently got in to programming (about two weeks ago).
I'm a civil engineer major but enjoy doing a lot of other non civil, engineering related projects on my free time.
As this is my first post, I just wanted to say, this website and the forums have taught me significantly more than my (for some reason) required semester of ANSI C ever taught me, and has compelled me to delve further in to the world of programming. I thank you all for this.
I began programming in c++ in order to produce, what I still consider to be, a "simple", turned based strategy game. Here is my 5th, maybe 6th iteration of the base of the code. I am trying to refine, and learn really what it is I am doing before I start adding too much to the code.
If you skipped that intro! I will now get to the point.
I am trying to randomize an array of 5 integers that for now can range from 1-10. Some of the code may not make sense at this point because of plans I have for it in the future, but currently:
I DO NOT RETURN VALUES RANGING FROM 1-10, WHICH IS WHAT I WISH FOR MY VALUES TO BE LIMITED TO. Currently, my first two integers are consistently between 1-10 and the third is in the 10^(4 or 5) range and the last two are in the hundreds.
Can you please help me figure out what is wrong with my code? I would like 5 integers between 1-10 to be assigned to the array "move_1_0"... and Thanks!
using namespace std;
int move_1_0 , reloop, i, y, n;
if (move_1_0[i] == 0) //move_<player>_<position> <1-5>
bool reloop = true;
move_1_0[i] = rand()%10+1; //<-Shouldn't this confine my random numbers to 1-10?
if(move_1_0[i] != move_1_0[y])
reloop = false;
/*in order to ensure no number shows up twice */
cout<<i+1<<") Move:"<<move_1_0[i]<<"\n"; //Should display the randomized numbers ranging from 1-10 in a list as 1-5?
(I am using Dev C++)
...and double thanks if you can help!