// Filename: Best Picks.cpp // Programmer: Josh Gager // Purpose: Suggests numbers to pick for the lottery #include "stdafx.h" #include <time.h> #using <mscorlib.dll> using namespace System; struct Lotto { int Pick_Five[54]; // Stores randomly picked numbers for 1-55 int Power_Ball[41]; // Stores Randomly picked numbers for 1-42 }; int random(int); int main() { Lotto Best_Pick; int T = 0; // Used for loops int Temp = 0; // Used to transfer numbers to different variables int Count_Best = 0; // Counts all of Pick_Five int Count_Ball = 0; // Counts all of Power_Ball // Sets Pick_Five and Power_Ball to 0 for(T=0; T<55; T++) { Best_Pick.Pick_Five[T] = 0; } for(T=0; T<42; T++) { Best_Pick.Power_Ball[T] = 0; } srand(time(NULL)); for(T=0; T<5000000; T++) { Temp = random(54); Best_Pick.Pick_Five[Temp]++; } // Once this is done running, Pick_Five has a total of 5mil numbers, as it should // But Power_Ball increases from 0 to some random number, which it shouldn't do Console::WriteLine(); // Output the numbers and how many times they were picked for(T=1; T<56; T++) { Console::WriteLine(" {0}:\t{1}",T.ToString(), Best_Pick.Pick_Five[T-1].ToString()); Count_Best += Best_Pick.Pick_Five[T-1]; } for(T=0; T<42; T++) { Count_Ball += Best_Pick.Power_Ball[T]; } Console::WriteLine(" {0}, {1}\n", Count_Best.ToString(), Count_Ball.ToString()); // Added Count_Best and Count_Ball to temporarily check how many numbers were being stored return 0; } // Purpose: Randomly generate a number from 0 to the Max // Recieved: The highest number to be generated // Output: A random number random(int Limit) { int Temp; Temp = rand() % (Limit + 1); return Temp; }

In a nutshell, one of my variables, Power_Ball, is picking up numbers somehow. Any help?