![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Newbie
Join Date: Apr 2007
Posts: 9
Rep Power: 0
![]() |
It compiled, and this seems to be the kind of program I am trying to create. How do I get it to stop asking for a number so It begin the random selection? It says to Enter a Number or 0 to exit. But when I enter a number as 0 it just saves it on the list.
|
|
|
|
|
|
#12 |
|
Professional Programmer
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 377
Rep Power: 0
![]() |
In the GetNumbers function change the if statement to:
if ( num == 0 )
break;
__________________
I am Addicted to Linux! |
|
|
|
|
|
#13 | |
|
Newbie
Join Date: Apr 2007
Posts: 9
Rep Power: 0
![]() |
Quote:
|
|
|
|
|
|
|
#14 |
|
Programmer
|
put either std::cin.get() or system( "pause" ) after the cout for the number to be displayed.
std::cout << numbers[choice - 1] << std::endl;
system ("pause");Like i said, i did this at work where I'm not even suppose to be coding, so didn't test it. |
|
|
|
|
|
#15 | |
|
Newbie
Join Date: Apr 2007
Posts: 9
Rep Power: 0
![]() |
Quote:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
srand((unsigned)time(0));
int random_integer;
int lowest=111, highest=999;
int range=(highest-lowest)+1;
for(int index=0; index<20; index++){
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
cout << random_integer << endl;
cin.get();
}I got this to generate 3 digit numbers. I'll mess around with both codes and see what else I can come up with. Once again thanks to everyone that has helped me. How can I get the number selector one to select a random number? |
|
|
|
|
|
|
#16 |
|
Programmer
|
This thread may help you with the random numbers.
For the picking a random number, just do what i dod for the above program, store the numbers in a array/vector ( vector is better ). Then pick the nth number from the vector. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Language display in program | Prm753 | C++ | 3 | May 30th, 2006 5:45 PM |
| Creating a program to test a program | sixstringartist | C | 8 | Jan 21st, 2006 1:15 PM |
| move program console window back | badbasser98 | C++ | 21 | Oct 18th, 2005 2:02 PM |
| Nonsense Name generator program | chillster13 | C | 14 | Jun 17th, 2005 2:05 AM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |