Raised This Month: $ Target: $400
 0% 

Setting an unique value to each cell of an array.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-25-2010 , 14:07   Re: Setting an unique value to each cell of an array.
Reply With Quote #3

Code:
public cmdPrint(id) {     new tmp[SIZE];     for(new i = 0; i < SIZE; i++)     {         tmp[i] = i + 1;     }     new rand, tsize = SIZE;     for(new i = 0; i < SIZE; i++)     {         rand = random(tsize);         var[i] = tmp[rand];         tmp[rand] = tmp[--tsize];         client_print(id, print_console, "Number: %d", var[i]);     } }
or
Code:
public cmdPrint(id) {     for(new i = 0; i < SIZE; i++)     {         var[i] = i + 1;     }         SortCustom1D(var, SIZE, "SortRandomVars");         for(new i = 0; i < SIZE; i++)     {         client_print(id, print_console, "Number: %d", var[i]);     } } public SortRandomVars(elem1, elem2, array[], data[], size) {     return clamp(random_num(-50, 50), -1, 1); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:15.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode