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

Username:   Password: 
 RegisterRegister   
 book ends
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
scorpion1087




PostPosted: Tue Nov 11, 2003 12:53 pm   Post subject: book ends

a book end is when you take a letter in a word and stop the word when you see the letter again. then show whats in the middle.

science-take the "C" therefore the word would be "cienc"
a skeleton for this would be great, thanks
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Nov 11, 2003 7:00 pm   Post subject: (No subject)

umm... just use substrings to read each letter at the time. Maybe this will help?
code:

var word:string := "science"

for i:1..length(word)
put word(i)
end for
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Dan




PostPosted: Tue Nov 11, 2003 7:12 pm   Post subject: (No subject)

he is a fast thing i made up

code:

var worad : string
var letter : string
var newString : string := ""
var flag : boolean := false
var num : int := 0

put "put in wroad"
get worad

put "what letter to use for book end?"
get letter


loop
    num += 1

    if flag then
        newString += worad(num)
    end if
   
    if worad (num) = letter and flag = false then
            flag := true
            newString += letter
    elsif worad(num) = letter and flag then
            exit
    end if
   
    if num = length (worad) then
        exit
    end if
end loop

put ""
put "output: ", newString


you have to use substrings to readed each letter of the worad. this verson still has a few bugs but should give you an idea on how to do it
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
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: