Question

I need to write a program that reads an command prompt argument (int n) that then outputs a cross made of Xs depending on the number, so an arg of 3 would output this

http://i.imgur.com/a441t0X.png

X would increase or decrease depending on the number in the arg

im not really sure how to go about this

Was it helpful?

Solution

Here's an algorithm (not actual code) for printing the cross (assuming the argument passed in is referred to as count):

LOOP(count times)
    LOOP(count times)
        PRINT space_character
    ENDLOOP
    PRINT "X"
    PRINT newline
ENDLOOP

LOOP(count times)
    PRINT "X"
ENDLOOP

PRINT " "

LOOP(count times)
    PRINT "X"
ENDLOOP

PRINT newline

LOOP(count times)
    LOOP(count times)
        PRINT space_character
    ENDLOOP
    PRINT "X"
    PRINT newline
ENDLOOP

OTHER TIPS

There are different ways to do this, the best way to start though is to break it up into loops.

So there would be a loop to create the first vertical section. Then one to produce the second horizontal and finally one to produces the last vertical section

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top