Click here to Skip to main content
15,894,343 members
Home / Discussions / C#
   

C#

 
GeneralRe: Including traditional C code in a C# project Pin
Andy Moore9-May-06 10:39
Andy Moore9-May-06 10:39 
QuestionHelp with Random integers Array Pin
eric_tran9-May-06 5:35
eric_tran9-May-06 5:35 
AnswerRe: Help with Random integers Array Pin
J4amieC9-May-06 5:38
J4amieC9-May-06 5:38 
AnswerRe: Help with Random integers Array Pin
conemajstor9-May-06 5:42
conemajstor9-May-06 5:42 
AnswerRe: Help with Random integers Array Pin
eric_tran9-May-06 5:50
eric_tran9-May-06 5:50 
GeneralRe: Help with Random integers Array Pin
conemajstor9-May-06 5:58
conemajstor9-May-06 5:58 
GeneralRe: Help with Random integers Array Pin
eric_tran9-May-06 6:12
eric_tran9-May-06 6:12 
AnswerRe: Help with Random integers Array Pin
Robert Rohde9-May-06 6:21
Robert Rohde9-May-06 6:21 
Like J4amieC suggested I would start by creating an array containing all your numbers sorted. Then just switch the numbers randomly in x iterations. Pick two random indices between 0 and 99999 and switch the two values in the array. If you make this long enough (probably 1 million times) than they should be ordered rather randomly.
int[] list = new int[100000];
for (int i = 0; i < list.Length; i++)
   list[i] = i;

Random r = new Random();

for (int i = 0; i < 1000000; i++)
{
   int i1 = r.Next(0, list.Length);
   int i2 = r.Next(0, list.Length);
   int temp = list[i1];
   list[i1] = list[i2];
   list[i2] = temp;
}

int counter = 0;
for (int i = 0; i < list.Length; i++)
   if (i == list[i])
      counter++;

GeneralRe: Help with Random integers Array Pin
eric_tran9-May-06 6:30
eric_tran9-May-06 6:30 
GeneralRe: Help with Random integers Array Pin
Wjousts9-May-06 7:14
Wjousts9-May-06 7:14 
GeneralRe: Help with Random integers Array Pin
Robert Rohde9-May-06 8:00
Robert Rohde9-May-06 8:00 
GeneralRe: Help with Random integers Array Pin
Wjousts9-May-06 8:08
Wjousts9-May-06 8:08 
GeneralRe: Help with Random integers Array Pin
Robert Rohde9-May-06 8:41
Robert Rohde9-May-06 8:41 
GeneralRe: Help with Random integers Array Pin
Rob Philpott10-May-06 0:37
Rob Philpott10-May-06 0:37 
AnswerRe: Help with Random integers Array Pin
Wjousts9-May-06 7:09
Wjousts9-May-06 7:09 
QuestionHow to change the color of scroll bar in c# desktop Application ? Pin
Jax_qqq9-May-06 5:22
Jax_qqq9-May-06 5:22 
QuestionHow to change the color of scroll bar in c# desktop Application ? Pin
Jax_qqq9-May-06 5:18
Jax_qqq9-May-06 5:18 
AnswerRe: How to change the color of scroll bar in c# desktop Application ? Pin
Josh Smith9-May-06 5:22
Josh Smith9-May-06 5:22 
Question[Localizable(true)] Pin
Soundman32.29-May-06 5:12
Soundman32.29-May-06 5:12 
AnswerRe: [Localizable(true)] Pin
Robert Rohde9-May-06 6:29
Robert Rohde9-May-06 6:29 
GeneralRe: [Localizable(true)] Pin
Soundman32.29-May-06 22:30
Soundman32.29-May-06 22:30 
QuestionC# to jar Pin
conemajstor9-May-06 4:44
conemajstor9-May-06 4:44 
AnswerRe: C# to jar Pin
Ravi Bhavnani9-May-06 4:50
professionalRavi Bhavnani9-May-06 4:50 
GeneralRe: C# to jar Pin
conemajstor9-May-06 4:52
conemajstor9-May-06 4:52 
GeneralRe: C# to jar Pin
Ravi Bhavnani9-May-06 6:58
professionalRavi Bhavnani9-May-06 6:58 

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.