Jump to content

Loss of numbers


Recommended Posts

Okay so I created a simple script to sort out a list of numbers generated by itself.

However, i find that the list of results has several missing numbers.

Why is this? I set up msg boxes and stuff everywhere to see if it's doing something wrong, but it's not...

#include <Array.au3>
Dim $d[105]
Dim $fin[105]
For $i = 1 To 100
    $d[$i] = Random(0,1000,1)
Next
For $k = 1 To 100
    $max = 0
    $CVAR = $d[$k]
    For $i = 1 To 100
        If $CVAR > $d[$i] Then $max += 1
    Next
    $fin[$max + 1] = $CVAR
Next
_ArrayDisplay($fin)

Thanks

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Okay so I created a simple script to sort out a list of numbers generated by itself.

However, i find that the list of results has several missing numbers.

Why is this? I set up msg boxes and stuff everywhere to see if it's doing something wrong, but it's not...

#include <Array.au3>
Dim $d[105]
Dim $fin[105]
For $i = 1 To 100
    $d[$i] = Random(0,1000,1)
Next
For $k = 1 To 100
    $max = 0
    $CVAR = $d[$k]
    For $i = 1 To 100
        If $CVAR > $d[$i] Then $max += 1
    Next
    $fin[$max + 1] = $CVAR
Next
_ArrayDisplay($fin)

Thanks

The missing numbers are those generated twice or more. (ex: if you have the number 55 generated twice it will appear only once in your final list)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Oh, wow, I thought I ruled that out by making it generate numbers within a larger range ^_^

Thanks alot. That hurt my brain for a while. I couldn't understand how I mess up on such a small script...

Edited by VindicatorOmega

[center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...