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

Username:   Password: 
 RegisterRegister   
 Drawing a Cross using Asterisks in Turing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Reira




PostPosted: Wed Nov 14, 2007 8:21 pm   Post subject: Drawing a Cross using Asterisks in Turing

here is the code.
code:

var column:int:=1
var row:int:=1
put repeat ("*", 80)
loop
    locate (row, column)
    put "*"
    column := column + 1
    if column > 80 then
        column := 1
    end if
    delay (100)
    cls

        locate (column, row )
    put "*"
    column := column - 1
    if column < 80 then
        column := 80
    end if


    locate (row, column)
    put "*"
    column := column + 1
    if column > 25 then
        column := 1
    end if
    delay (100)
    cls


        locate (column, row )
    put "*"
    column := column - 1
    if column < 80 then
        column := 1
    end if


    cls
end loop
Sponsor
Sponsor
Sponsor
sponsor
Nick




PostPosted: Wed Nov 14, 2007 8:25 pm   Post subject: RE:Drawing a Cross using Asterisks in Turing

so do u want something like
code:

 *
***
 *
or a giant one?
Reira




PostPosted: Wed Nov 14, 2007 8:26 pm   Post subject: RE:Drawing a Cross using Asterisks in Turing

yup, a giant one.
a small one would be too easy, hehe ^^
Nick




PostPosted: Wed Nov 14, 2007 8:34 pm   Post subject: Re: Drawing a Cross using Asterisks in Turing

ok ill go step by step

first get rid of put reapeat and your row varible

second replace your loop with 1 for and 1 for decreasing loop one after the other both called row

third in both loops keep only
Quote:
locate (row, column)
put "*"
column := column + 1
if column > 80 then
column := 1
end if
delay (100)


finally in between the 2 loops have a line to reset column back to 1
CodeMonkey2000




PostPosted: Wed Nov 14, 2007 8:35 pm   Post subject: Re: Drawing a Cross using Asterisks in Turing

Like this?
code:
var column : int := 1
var row : int := 1
locate (maxrow div 2, 1)
put repeat ("*", maxcol)
for x : 1 .. maxrow
    locate (x, maxcol div 2)
    put "*" ..
end for
Reira




PostPosted: Wed Nov 14, 2007 8:46 pm   Post subject: RE:Drawing a Cross using Asterisks in Turing

hmmm wow this makes things much shorter...
i thought this would take at least four "for" loops... i saw someone in my class do this in a much longer code. and the teacher told me to do a loop for each line... ah well thanks momop for your explanation... I finally get it! And CodeMonkey, you did it quite differently from the way people attempted to do this in my CompSci class... but this version is much shorter than any version I have seen so far. Anways, thanks for your help! ^^
Now, it's time to memorise... o_0
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  [ 6 Posts ]
Jump to:   


Style:  
Search: