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

Username:   Password: 
 RegisterRegister   
 Need help identifying a function
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
KC 40oz




PostPosted: Tue Nov 15, 2005 10:03 am   Post subject: Need help identifying a function

I'm making a binary -> decimal convertor and i need the function that counts the # of digits in a variable and also that can grab single digits
i am SURE i learned this last year, but the help file at my school isnt working right now
any help would be appreciated
Sponsor
Sponsor
Sponsor
sponsor
ZeroPaladn




PostPosted: Tue Nov 15, 2005 10:20 am   Post subject: (No subject)

lolz, i did this for extra credit this september, although i didnt know that there was a function for it Crying or Very sad . What i did is that i used the number 256 (1 as the 9th digit of binary) and kept deviding it by 2, then checking to see if i could minus certain numbers from it. heres the post for it, and there are tons of other submissions for it too. study it.
http://www.compsci.ca/v2/viewtopic.php?t=9806
Albrecd




PostPosted: Tue Nov 15, 2005 10:40 am   Post subject: length

Use "length (variable)"

Ex:
code:
var a :string
put "Write something"
get a:*
put "The length of your writing masterpiece is ",length (a)," characters."
do_pete




PostPosted: Tue Nov 15, 2005 11:27 am   Post subject: (No subject)

length(variable) is for strings. So in order to use that you would have to convert the interger into a string using intstr()
KC 40oz




PostPosted: Tue Nov 15, 2005 12:37 pm   Post subject: (No subject)

ok thanks, i also need to be able to extract a certain char from the string, and i remember doing that yet cant remember for the life of me what the function was
i remember it including * s to signify the last char in the string
do_pete




PostPosted: Tue Nov 15, 2005 12:49 pm   Post subject: (No subject)

i don't know about the *s but you just go something like this
code:
Character:=String(number)

Character is the character you want to isolate. String is the string and number is the number of the character. for example this would print "r" becuase "r" is the third character in the string "turing"
code:
var text:string:="turing"
put text(3)
codemage




PostPosted: Tue Nov 15, 2005 1:09 pm   Post subject: (No subject)

Treat strings like you would arrays of characters.

var x : string := "abcdefghijklmn"
put x (3)
-> puts out "c"

put x (5..*-2)
- >puts out "efghijkl"

You can use index and length for more in-depth string manipulation.
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  [ 7 Posts ]
Jump to:   


Style:  
Search: