Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 sorting name help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bluedevils_77




PostPosted: Wed Dec 20, 2006 10:41 am   Post subject: sorting name help

var fileID : int
open : fileID, "highscores.txt", get
assert fileID > 0
var line : string

var count : int := 0

loop
get : fileID, line : *
count := count + 1
exit when eof (fileID)

end loop

close : fileID
open : fileID, "highscores.txt", get

var namelist : array 1 .. count of string
var list : array 1 .. count of int
for i : 1 .. count
get : fileID, namelist (i)
get : fileID,list(i)
end for



var sortList : array 1 .. count of int
var sortNameList : array 1 .. count of string
for i : 1 .. count
var smallest := 1000000000
var where : int
var Namesmallest := "ZZZ"
for j : 1 .. count
if list (j) < smallest then
smallest := list (j)
where := j

end if

end for
sortNameList (i) := Namesmallest
sortList (i) := smallest
list (where) := 1000000000
end for
put "here are the numbers in ascending order"
for decreasing i : count .. 1
put "",sortNameList(i)," ",sortList(i),""
end for

im tryin to liek sort the socres wtih certain names, but i dunt know how to sort the names wiht it
Sponsor
Sponsor
Sponsor
sponsor
ZeroPaladn




PostPosted: Wed Dec 20, 2006 1:19 pm   Post subject: (No subject)

Think about what your asking for a moment...
Quote:
im tryin to liek sort the socres wtih certain names, but i dunt know how to sort the names wiht it

Your asking on how to sort the names with it! Since you know arrays (from looking at your code), it's easy! When you go to sort the scores using whatever sorting procedure you'll be using, just sort the names as well. It's one extra line of code.
psuedo:
...
list(i) := list(i + 1)
namelist(i) := namelist(i + 1)
...

This is just an example, but the idea behind it is easy. Good luck.
TokenHerbz




PostPosted: Wed Dec 20, 2006 4:05 pm   Post subject: (No subject)

shrink your pic too, 100x100 @ <= 6kb max
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: