Click here to Skip to main content
15,920,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: please help !!generation of uniform random numbers Pin
Archer justice16-Nov-09 0:54
Archer justice16-Nov-09 0:54 
QuestionRe: please help !!generation of uniform random numbers Pin
CPallini16-Nov-09 1:01
mveCPallini16-Nov-09 1:01 
AnswerRe: please help !!generation of uniform random numbers Pin
Archer justice16-Nov-09 1:06
Archer justice16-Nov-09 1:06 
QuestionHelp: How to autofit CListCtrl's background? Pin
Symfund15-Nov-09 22:49
Symfund15-Nov-09 22:49 
AnswerRe: Help: How to autofit CListCtrl's background? Pin
Ahmed Charfeddine16-Nov-09 0:12
Ahmed Charfeddine16-Nov-09 0:12 
GeneralRe: Help: How to autofit CListCtrl's background? Pin
Symfund16-Nov-09 1:36
Symfund16-Nov-09 1:36 
Questiondde Pin
trioum15-Nov-09 20:01
trioum15-Nov-09 20:01 
AnswerRe: dde Pin
Maxwell Chen15-Nov-09 22:26
Maxwell Chen15-Nov-09 22:26 
GeneralRe: dde Pin
trioum15-Nov-09 23:31
trioum15-Nov-09 23:31 
GeneralRe: dde Pin
Maxwell Chen16-Nov-09 1:13
Maxwell Chen16-Nov-09 1:13 
QuestionMultiple Inheritance problem Pin
Rahul Vaishnav15-Nov-09 19:34
Rahul Vaishnav15-Nov-09 19:34 
AnswerRe: Multiple Inheritance problem Pin
Symfund15-Nov-09 20:11
Symfund15-Nov-09 20:11 
GeneralRe: Multiple Inheritance problem Pin
Rahul Vaishnav15-Nov-09 20:32
Rahul Vaishnav15-Nov-09 20:32 
GeneralRe: Multiple Inheritance problem Pin
CPallini15-Nov-09 20:53
mveCPallini15-Nov-09 20:53 
AnswerRe: Multiple Inheritance problem Pin
Symfund15-Nov-09 22:08
Symfund15-Nov-09 22:08 
AnswerRe: Multiple Inheritance problem Pin
Naveen15-Nov-09 20:39
Naveen15-Nov-09 20:39 
GeneralRe: Multiple Inheritance problem Pin
Rahul Vaishnav15-Nov-09 22:01
Rahul Vaishnav15-Nov-09 22:01 
QuestionRe: Multiple Inheritance problem Pin
CPallini15-Nov-09 20:51
mveCPallini15-Nov-09 20:51 
QuestionRuuning MFC Exe without Oracle Client Pin
hellogany15-Nov-09 17:51
hellogany15-Nov-09 17:51 
Answer[Message Deleted] Pin
Rahul Vaishnav15-Nov-09 19:26
Rahul Vaishnav15-Nov-09 19:26 
GeneralRe: Ruuning MFC Exe without Oracle Client [modified] Pin
Shameel16-Nov-09 5:01
professionalShameel16-Nov-09 5:01 
QuestionHow to store a file in a single variable? Pin
Paulraj G15-Nov-09 17:44
Paulraj G15-Nov-09 17:44 
AnswerRe: How to store a file in a single variable? Pin
Adam Roderick J15-Nov-09 18:20
Adam Roderick J15-Nov-09 18:20 
GeneralRe: How to store a file in a single variable? Pin
Paulraj G15-Nov-09 18:22
Paulraj G15-Nov-09 18:22 
Questionprint it only if it is not a duplicate [modified][solved] Pin
Omegaclass15-Nov-09 14:01
Omegaclass15-Nov-09 14:01 
what is wrong with my code it's kicking me in the head right now and if a kind soul could help me out i would be very grateful, thanks.


here is the goal:

Use a one dimensional array to solve the following problem. Read in 20 numbers,
each of which is between 10 and 100, inclusive. As each number is read, print it only if it
is not a duplicate of a number already read. Provide for the “worst case” in which all 20
numbers are different. Use the smallest possible array to solve this problem.Well,



#include <iostream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
#include <limits>
const int x = 20;
using namespace std;


int main()

{ 
	
                  int i = 0;
                  int toss = 0;
	              int count=0;
                  int population[20];
                  int num=0;
	              bool duplicate = false;
                  
 
		      while(1)
              { 
                  			   
	              for (int j = 0; j < x; j++)    // test for duplicate random num
	              {
                     
                      srand(time(NULL));
                      num = rand()%90+11;
                      
                    if (num == population[j])
			    
                    {
					duplicate = true;
			        toss++;
				    //break; 
                    }  // exit the loop if true 
		        
                
                    if (!duplicate)
                    {   // if not duplicate
			          
                     population[j] = num;  // fill the dynamic array
                     count++;
                     } 
                  }

			   
                   
                   for (int ii = 0; ii <= count; ii++)
                   {
                   cout << population[ii]<<" ";
                   }
                   cin.clear();
                   cin.get();
                   }
                   }

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.