Writing pseudocode?

How would you write a pseudo-code to draw a checkerboard of squares of size 8 by 8, where none of the squares should be filled? (Everything can be empty)

I do not quite understand the concept of pseudocode.

+3
source share
5 answers

I would be even more general, for example.

Loop with x from 1 to 8
    Loop with y from 1 to 8
        draw square at x, y
+5
source

Pseudocode writes out code in a form that is similar to code, but not exactly code. So, to open the file and print, print its lines of text

if file exists(path_to_file) then :
 open (path_to_file)
 for each line in file  : print the line of the file

All you have to do is create a sequence of steps necessary for your problem and write it like this. Since you mention python, just use in your pseudo-code more syntax like python.

, , , , .

+4

Pseudocode. Pseudocode wikipedia, , :

Pseudocode ():

, , :

for i from 0 to 7
    for j from 0 to 7
        if (i + j) is even then
            paint square (i, j) black
        else
            paint square (i, j) white

( if end of "end if" "repeat" / "end for" - , ).

+3

-, .

for i from 1 to 8
    for j from 1 to 8
        print "[ ]"
    print "\n"
+2

, , ?

In short, pseudo code is very similar to a loop. This is the structure of how you are going to solve the problem, without specific details.

In this case, you are likely to use a pair of for-loops and draw a picture there too ...

for x in range(0,10):
    for y in range(0,10):
        #print out the square (x,y)
+1
source

Source: https://habr.com/ru/post/1718135/


All Articles