Qbasicnews.com
April 08, 2020, 07:45:07 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Greater & Less Than  (Read 8774 times)
The_Names_Gin
New Member

Posts: 21


« on: April 23, 2006, 05:28:51 PM »

All right, I have a big number group from 1 to 52,

Now lets say, I want only numbers 3, 16, 29, 43 to be the lowest of all the numbers

BUT

I want 4, 17, 30, 44, to be slightly higher but not greater than 5, 18, 31, 45

Making it in layers like so

Example:

3, 16, 29, 43 is less than 4, 17, 30, 44
4, 17, 30, 44 is less than 5, 18, 31, 45 but greater than 3, 16, 29, 43
5, 18, 31, 45 is less than 6, 19, 32, 46 but greater than 4, 17, 30, 44 & so on...
Logged
Dio
I hold this place together
*****
Posts: 874



« Reply #1 on: April 23, 2006, 06:56:04 PM »

ok, did anybody else catch that?
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
RyanKelly
Forum Regular
**
Posts: 109



WWW
« Reply #2 on: April 23, 2006, 07:41:52 PM »

I'm sorry.  Your question is beyond vague.

Quote
All right, I have a big number group from 1 to 52,

Explain what you mean by "have a big number group".
Is this an array?  Are they in a files?  Are your individual data types the numbers themselves or groups of numbers?

Quote

Now lets say, I want only numbers 3, 16, 29, 43 to be the lowest of all the numbers



All the lists you posted follow this pattern,

x, x+3, x+13, x + 14.

Does this hold true for every group you want to work with?

Give us a brief description of the broader context you're working in.
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #3 on: April 23, 2006, 07:41:53 PM »

Ok
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #4 on: April 23, 2006, 07:42:39 PM »

Also, for those who dont get it yet.. he wants to sort a deck of cards...
Logged
The_Names_Gin
New Member

Posts: 21


« Reply #5 on: April 23, 2006, 08:52:02 PM »

Quote from: "Z!re"
Also, for those who dont get it yet.. he wants to sort a deck of cards...


Yeah something on the concept of that idea.

1, 14, 27, 40 -Lowest
2, 15, 28, 41
3, 16, 29, 42
4, 17, 30, 43
5, 18, 31, 44
6, 19, 32, 45
7, 20, 33, 46
8, 21, 34, 47
9, 22, 35, 48
10, 23, 36, 49
11, 24, 37, 50
12, 25, 38, 51
13, 26, 39, 52 -Highest

Each one of the numbers is going to be something on the lines of

if num = 42 then
print "Example 52"

else goto 10

if num = 16 then
print "Example 11"
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #6 on: April 23, 2006, 08:54:33 PM »

Ok, I dont get it..
Logged
The_Names_Gin
New Member

Posts: 21


« Reply #7 on: April 23, 2006, 09:08:46 PM »

Quote from: "Z!re"
Ok, I dont get it..


It's like um...

When chosen, each number will print out something different.

Like: If num = 12 then PRINT "Example 40"

the user presses a button & it randomly shoots out 5 numbers, lets say..

17,      40,     12,    38,     45
slot1, slot2, slot3, slot4, slot5,

.. For instance.

The program will look at the five numbers/slots

Deciding which one is higher,

In my diagram of 1 - 50 we can clearly see 12 is the highest & 40 is the lowest.

I want it to than spit out to the user the highest number (12) in a string.
Logged
Dio
I hold this place together
*****
Posts: 874



« Reply #8 on: April 23, 2006, 09:58:19 PM »

Quote from: "RyanKelly"
I'm sorry.  Your question is beyond vague.

:laughing:

Quote from: "Z!re"
Ok, I dont get it..


ok, just so as long that i'm not thee only one here
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Deleter
Na_th_an
*****
Posts: 1293



WWW
« Reply #9 on: April 23, 2006, 10:10:57 PM »

The more he posts, the more lost I get  :Huh:
Logged

Pritchard
Wandering Guru
***
Posts: 328


« Reply #10 on: April 23, 2006, 10:28:44 PM »

Just a suggestion, but couldn't you dim the array (0 to 12, 0 to 3) '0 to 3 for four types.  Have it throw out a random card from there. This way you can use the first spot in that array (x, y) 'x in this case, to check the value of the card.

I hope this is somewhere NEAR what you are asking, otherwise I'm amazingly confused, or...More amazingly confused than I already am.

For example:
Code:
'Dim stuff here:
dim card_Deck (0 to 12, 0 to 3) 'This will be our card deck array
dim card(0 to 5) 'Six cards at hand

'Create the deck!
for load = 0 to 12
    for load_2 = 0 to 3
        card_deck(load, load_2) = load
    next
next

'Make a hand
for card_throw = lbound(card) to ubound(card)
    card_type = int(rnd * 3)
    card_value = int(rnd * 12)
    card(card_Throw) = card_deck(card_value, card_type)
next

'Print the Values of the hand:
for card_throw = lbound(card) to ubound(card)
    print card(card_throw)
next
print "Total value is:", card(0) + card(1) + card(2) + card(3) + card(4) + card(5)
sleep
Logged

 will Live Forever, or Die Trying >_<;;
stylin
Ancient QBer
****
Posts: 445


« Reply #11 on: April 24, 2006, 12:41:14 AM »

You could use an array, but that's a little inefficient. Here, you can rely on the fact that the numbers in your diagram are simply the reversed-ordered elements in an array (all we need to do is find the column the number would be in):

Code:

'/ returns the column the element n would be in with an
'/ array width of highestPriority
function GetPriority(n as integer, highestPriority as integer) as integer
   return (n-1) mod highestPriority
end function

   '/ create an array to hold the random nums
   const MaxSlots as integer = 5
   dim slots(0 to MaxSlots-1) as integer
   
   '/ fill slots with random numbers
   '/ ...

   '/ find the number with highest priority
   dim highestPriority as integer = 0

   dim slot as integer
   for slot = 0 to MaxSlots-1
      dim priority as integer = GetPriority(slots(slot),13)
      if (highestPriority < priority) then
         highestPriority = priority
      end if
   next

   '/ highestPriority now contains the slot with
   '/ the highest priority :)
Logged

stylin:
stylin
Ancient QBer
****
Posts: 445


« Reply #12 on: April 24, 2006, 12:44:47 AM »

My internet's borked, so I had to shorten my code above so I could post it. Just wanted to add that you should get rid of that literal '13' and replace it with a constant - or a var, if you'd like to change the array width (max priority) at run-time.

EDIT: and you'll have to actually save the slot along with the highest priority. (my code just keeps track of the priority) Shocked
Logged

stylin:
The_Names_Gin
New Member

Posts: 21


« Reply #13 on: April 24, 2006, 02:19:26 PM »

I took a different route by using DIM commands,

but now I get a duplicate error

1 = 1
14 = 1
27 = 1
40 = 1
Logged
stylin
Ancient QBer
****
Posts: 445


« Reply #14 on: April 24, 2006, 02:22:32 PM »

Let me consult my crystal ball ... it tells me I need more information [IOW, nobody is a mind-reader here]. You might want to post some code. Sorry.
Logged

stylin:
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!