What will be algo for print a matrix of the order n(given as input by user) and always odd number.
Example: In user give n = 7 Output will be
1 1 开发者_如何学Go1 1 1 1 1 1 0 0 0 0 0 1 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1Consider we want to print point (x, y) (the center is (0, 0)). Take max(abs(x), abs(y)) and look if it is odd or even and print 0 for even and 1 for odd.
You should iterate from y = n / 2 to y = - n / 2 and the trough x = - n / 2 to x = n / 2
Sorry for my poor English
精彩评论