Microsoft Interview Question
Software Engineer / DevelopersGiven pixel(x, y) element in the 1D array is x*800+y.
To add Monochrome doesn't mean just one color. It is shades of a single color.
If the pixels are stored in row major, we need to set the array's index(say i) given x, y.
and assuming 1,1 is at top left corner and array index starts from 0
i = (y-1)*800 + (x - 1)
screen resolution is columns x rows
What do you mean by setting a pixel exactly? Is it setting the value to 1? Since it is a monochrome monitor, all we have is Os and 1s. If the image is of size 800 by 600, then we need an array as big as 800 * 600 (800 rows and 600 cols). So, iterate through each element in the array and keep track of the cols and rows and set the bits accordingly..please correct me if I am wrong...
- noviceprog September 27, 2008