Click here to Skip to main content
15,921,062 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOnPaint vr. DrawItem Pin
jason9926-Oct-05 5:39
jason9926-Oct-05 5:39 
AnswerRe: OnPaint vr. DrawItem Pin
Chris Losinger26-Oct-05 5:53
professionalChris Losinger26-Oct-05 5:53 
GeneralRe: OnPaint vr. DrawItem Pin
PJ Arends26-Oct-05 9:27
professionalPJ Arends26-Oct-05 9:27 
GeneralRe: OnPaint vr. DrawItem Pin
Chris Losinger26-Oct-05 9:35
professionalChris Losinger26-Oct-05 9:35 
Questionprint blank pages Pin
valerie9926-Oct-05 5:16
valerie9926-Oct-05 5:16 
Questiontoolbar for Outlook Express Pin
Anonymous26-Oct-05 4:30
Anonymous26-Oct-05 4:30 
AnswerRe: toolbar for Outlook Express Pin
andy14526-Oct-05 23:51
andy14526-Oct-05 23:51 
Questionrandom number that doesn't repeat? Pin
aaadetos26-Oct-05 4:24
aaadetos26-Oct-05 4:24 
Hi I'm trying to do the following:
1) generate a random # from the array layer_array[]
2) swap the number generated with a negative number, to avoid repetition of that random #.

I'm not sure I'm correctly sampling from layer_array[]. And I'm definitely not implementing swap() correctly....how would i proceed?

Please help.
// rgen.cpp : Defines the entry point for the console application.<br />
//<br />
<br />
#include <cmath><br />
#include "stdafx.h"<br />
#include <ctime><br />
#include <cstdlib><br />
#include <algorithm><br />
#include <fstream><br />
#include <iostream><br />
#include <iomanip><br />
using namespace std;<br />
<br />
int main()<br />
{<br />
	const int size = 20;<br />
<br />
	//initialize all elements of the layer array to zero.<br />
	int layer_array[size]={0};<br />
<br />
	//re-initialize the array elements by incrementing...good if u got a million variables...<br />
	for(int i=0; i<size; i++)<br />
		 layer_array[i]=i+1;<br />
<br />
	//seed the random # generator using the system time<br />
	srand((unsigned)time(0)); <br />
<br />
	int random_integer[size] ={0};//initialize the array of random numbers<br />
<br />
	for(int index=0; index<size; index++)<br />
	{<br />
		random_integer[index] = (rand()%size)+1; <br />
		swap(&layer_array[index],&layer_array[index*-1]);//error c2664<br />
<br />
		cout << random_integer[index] << endl; <br />
	}<br />
<br />
    return 0;<br />
}<br />

AnswerRe: random number that doesn't repeat? Pin
David Crow26-Oct-05 4:30
David Crow26-Oct-05 4:30 
GeneralRe: random number that doesn't repeat? Pin
John R. Shaw26-Oct-05 15:20
John R. Shaw26-Oct-05 15:20 
AnswerRe: random number that doesn't repeat? Pin
toxcct26-Oct-05 5:03
toxcct26-Oct-05 5:03 
AnswerRe: random number that doesn't repeat? Pin
Joe Woodbury26-Oct-05 6:31
professionalJoe Woodbury26-Oct-05 6:31 
AnswerRe: random number that doesn't repeat? Pin
__yb27-Oct-05 2:18
__yb27-Oct-05 2:18 
QuestionPlease Help with CAsyncSocket Pin
cgb14326-Oct-05 4:17
cgb14326-Oct-05 4:17 
AnswerRe: Please Help with CAsyncSocket Pin
Moak4-Nov-05 8:39
Moak4-Nov-05 8:39 
Questionefficient 'push&amp;hold' button ? Pin
ganjabro26-Oct-05 4:07
ganjabro26-Oct-05 4:07 
AnswerRe: efficient 'push&amp;hold' button ? Pin
David Crow26-Oct-05 4:25
David Crow26-Oct-05 4:25 
GeneralRe: efficient 'push&amp;hold' button ? Pin
Anonymous26-Oct-05 7:02
Anonymous26-Oct-05 7:02 
QuestionRe: efficient 'push&amp;hold' button ? Pin
David Crow26-Oct-05 7:10
David Crow26-Oct-05 7:10 
AnswerRe: efficient 'push&amp;hold' button ? Pin
ganjabro26-Oct-05 8:35
ganjabro26-Oct-05 8:35 
GeneralRe: efficient 'push&amp;hold' button ? Pin
ganjabro26-Oct-05 8:41
ganjabro26-Oct-05 8:41 
QuestionHow to get the actual value? Pin
ShiningStarPxx26-Oct-05 3:43
ShiningStarPxx26-Oct-05 3:43 
AnswerRe: How to get the actual value? Pin
Cedric Moonen26-Oct-05 3:46
Cedric Moonen26-Oct-05 3:46 
GeneralRe: How to get the actual value? Pin
ShiningStarPxx26-Oct-05 20:08
ShiningStarPxx26-Oct-05 20:08 
GeneralRe: How to get the actual value? Pin
Cedric Moonen26-Oct-05 20:41
Cedric Moonen26-Oct-05 20:41 

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.