Computer Science Canada

abc

Author:  mercuryy [ Sat Mar 12, 2005 5:21 pm ]
Post subject:  abc

How can you output something like
code:

A A A A A A
* B B B B B
* * C C C C
* * * D D D
* * * * *E E
* * * * * *G

using counted loop?

* indicate space

Author:  Cervantes [ Sat Mar 12, 2005 7:54 pm ]
Post subject: 

What have you got so far? What are your ideas?
These problems are best for you to do. You don't learn if we give you the answer. But we can help you. So, on those lines, what are your ideas?

Author:  mercuryy [ Sat Mar 12, 2005 8:04 pm ]
Post subject: 

what i got is

code:
for decreasing row:26..1
for col:1..26-row

put chr(row+64):3..

end for
delay (56)
put " "
end for


but than i can't get it to "flip" to the other side. Embarassed [/code]

Author:  ssr [ Sat Mar 12, 2005 8:30 pm ]
Post subject: 

I thnk what my teacher did on this quesion is do one loop for teh "*" and one loop for letters... 8)

Author:  mercuryy [ Sat Mar 12, 2005 8:39 pm ]
Post subject: 

yeah. but i tried that too.

code:
for  decreasing row:26..1
for  decreasing col:row..1
put chr(row+64):3..
end for
put " "
end for


here is another way i tried. but the ouput is still on the "wrong" side.

Author:  Token [ Sat Mar 12, 2005 8:40 pm ]
Post subject: 

yah we had to do this one too, heres a hint to how i solved it

code:

var letters :string :="ABCDEFG"
var counter:int


then

code:

counter +=1
letters(counter)

also look up length in the help file, hope this helps

Author:  ssr [ Sat Mar 12, 2005 8:49 pm ]
Post subject: 

mercuryy wrote:
yeah. but i tried that too.

code:
for  decreasing row:26..1
for  decreasing col:row..1
put chr(row+64):3..
end for
put " "
end for


here is another way i tried. but the ouput is still on the "wrong" side.

my fault didnt explain it well
2 separate loops, I will post my code later on
eventually
...
yes
... 8)

Author:  mercuryy [ Mon Mar 14, 2005 9:02 pm ]
Post subject: 

so there are no other ways beside using the "length" function?

Author:  Token [ Mon Mar 14, 2005 10:03 pm ]
Post subject: 

i'm sure theres way more than that way, for example. maybe look at the chr and ord functions and think about doing a for statement somthing like

code:

for i:65..71


but really you need to look at the help file to understand that

Author:  ssr [ Mon Mar 14, 2005 10:19 pm ]
Post subject: 

lol ord and chr arent that hard
code:
var chars:char
var ints: int
get chars
get :ints
ord (chars)
chr(ints)

it basically get a char and convert it into a ACSII number also it gets a ACSII number and convert it into a char.
***
I know u know how to do it token
just saying its not hard Very Happy

Author:  Token [ Mon Mar 14, 2005 10:22 pm ]
Post subject: 

lol i know Sirui Song , i was just saying i didnt feel like explaining it t him so he'd have to look it up for himself Laughing but u took care of that for me didnt ya Wink

Author:  ssr [ Mon Mar 14, 2005 10:26 pm ]
Post subject: 

lol, I knew I should spread my name all around the internet... Very Happy

Author:  Flikerator [ Tue Mar 15, 2005 1:56 pm ]
Post subject: 

code:
var let : string := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i : 1 .. length (let)
    for ii : 1 .. length (let) + 1 - i
        put let (i) ..
    end for
    put ""
    delay (50)
end for


Is that what you want? I don't think it is but maybe use it to do what you want?

Author:  Token [ Tue Mar 15, 2005 2:24 pm ]
Post subject: 

Flickerator thats basically what i did, only the thing is u have to do it the oposite way, so that they form against an imaginary margin on the right side, this is how i did it

code:

var letters : string := "ZYXWVUTSRQPONMLIJIHGFEDCBA"
for decreasing i : length (letters) .. 1
    for j : 1 .. length (letters) - i
        put " " ..
    end for
    for j : 1 .. i
        put letters (i) ..
        delay (10)
    end for
    put " "
    delay (10)
end for


and you can change it to say ne thing u want, but it has to be backwards

Author:  Flikerator [ Tue Mar 15, 2005 3:03 pm ]
Post subject: 

Token wrote:
Flickerator thats basically what i did, only the thing is u have to do it the oposite way, so that they form against an imaginary margin on the right side, this is how i did it

code:

var letters : string := "ZYXWVUTSRQPONMLIJIHGFEDCBA"
for decreasing i : length (letters) .. 1
    for j : 1 .. length (letters) - i
        put " " ..
    end for
    for j : 1 .. i
        put letters (i) ..
        delay (10)
    end for
    put " "
    delay (10)
end for


and you can change it to say ne thing u want, but it has to be backwards

Well you could take the original word and just make it backwords. That way you could ask the person for a word and they could still do it Razz

Author:  Token [ Tue Mar 15, 2005 3:17 pm ]
Post subject: 

yah you could, or you could even go one step further and get the input from the user and make that backwards. (i didnt feel like taking the variable and turning it around, it just takes up more space, but this isnt so bad... an extra 8 lines)

code:
var letters : string := ""
var word : string % := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var counter : int

put "Enter the word: " .. %%this line
get word                  %%this one too

for decreasing i : length (word) .. 1
    letters += word (i)
end for
cls
delay (500)
for decreasing i : length (letters) .. 1

    for j : 1 .. length (letters) - i
        put " " ..

    end for
    for j : 1 .. i
        put letters (i) ..
        delay (10)
    end for
    put " "
    delay (10)
end for


to make it work without the get, uncomment the 2nd line and comment the marked lines (5,6)


: