Home › Forums › C Programming › Beginner Help › Reply To: Beginner Help
July 27, 2007 at 7:33 am
#3240
S.Thananchayan
Participant
You need loop to hit random off system time
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <iostream><br /> #include <ctime><br /> using namespace std;<br /> int main()<br /> {<br /> int a,b,c,d,e,f;<br /> string g,h="a";<br /> srand(time(0));<br /> loop:<br /> a = (rand()%10);<br /> b = (rand()%10);<br /> c = (rand()%10);<br /> d = (rand()%10);<br /> e = (rand()%10);<br /> f = (rand()%10);<br /> cout<<"n";<br /> cout << a;<br /> cout << b;<br /> cout << c;<br /> cout << d;<br /> cout << e;<br /> cout << f;<br /> cout<<"n";<br /> cout<<"n";<br /> cout<<"To create a new random number, press a and then enter.";<br /> getline (cin,g);<br /> if (g==h){<br /> goto loop;<br /> }<br /> cin.get();<br /> }<br /> </ctime></iostream> |