Computer Science Canada Hi i am having some problems |
Author: | shruti [ Wed Apr 02, 2008 4:34 pm ] |
Post subject: | Hi i am having some problems |
hi guys i am new. i have a question. i wrote this program where the output should be in alphabetical order but i am having some errors i dont know what it is. anotehr question is that if we have to replace every 4th cahracter in a word ...how to you do it ??? is there a formula or something ??????????? Quote: var word:string var word1 : string var word2 : string var word3 : string put " please enter the first word ex, cappa " get word1 put " please enter the second word ex, alpha" get word2 put " please enter the third word ex, beta" get word3 if (word1>word2) and (word1>word3) then put "The words in alphabetical order " elsif (word2<word1) or (word2>word3) then put "The words in alphabetical order " elsif ( word3<word1) or ( word3<word2) then put " the words in alphabetical orders are ", word1, word2, word3 elsif (word1=word2) and (word1=word3)then put " words are the same, smart !" elsif ( word2=word1) and (word2=word3) then put " words are the same, smart !" elsif ( word3=word1) and (word3=word2) then put " words are the same, smart!" end if put "The words in alphabetical order ", word1, word2, word3 get word1, word2, word3 i know that put "The words in alphabetical order ", word1, word2, word3" i shopuld not put word1..3 but i dont know what to do m plzzzzzzzzzzzzzzz help me ASAP thankyou ![]() |
Author: | Tony [ Wed Apr 02, 2008 4:55 pm ] | ||
Post subject: | RE:Hi i am having some problems | ||
what kind of error are you having? also... this makes little sense
|
Author: | shruti [ Wed Apr 02, 2008 5:02 pm ] |
Post subject: | RE:Hi i am having some problems |
its not exactly an error but if i put some words that's not in alphabetical order. it outputs word1,2,3. in the order taht i put ![]() |
Author: | Tony [ Wed Apr 02, 2008 5:33 pm ] |
Post subject: | RE:Hi i am having some problems |
well you did say specifically that put "The words in alphabetical order ", word1, word2, word3 what did you expect it to output there? |
Author: | shruti [ Wed Apr 02, 2008 5:40 pm ] |
Post subject: | RE:Hi i am having some problems |
i want the output to be that the words should be in alphbetical orderlike if you put ksr it will give what ever you put in but i want it in alphbetical order |
Author: | The_Bean [ Wed Apr 02, 2008 6:04 pm ] | ||||||||
Post subject: | Re: Hi i am having some problems | ||||||||
To start off, it's best to use an array when your holding 3 of the same thing. And it's also alot easier to manipulate later, and when you want to do it with 10 words. The reason that it puts them back out in the same order is because that is what your having it do.
Also get rid of the get word1, word2, word3 at the very end because it does nothing. Now in order to properly sort the list a simple bubble sort will do. But in order to use the bubble sort you need the words in an array. firstly declair your array, and the temporary variable you need for the bubble sort.
now to call them use either a "for" statement or word(1),word(2)... now that you have the words in its time to sort. Heres the bubble sort and how to use it
Now theres probably a better method but to change the 4th letter you can do it like this
|
Author: | shruti [ Fri Apr 04, 2008 6:41 am ] |
Post subject: | RE:Hi i am having some problems |
hey the Bean when i put the 1st command there is an errror i dont know why ! it says "syntax error at array" an for the 2nd one there is also an error and it should be every 4th letter ! the error is " variale has no value " ... plx help me |