javacode7
BAN USER- 0of 0 votes
AnswersGiven an image that is represented by Nx1000 matrix of binary numbers. 1 represents black(image ink) and 0 represents white(blank).
- javacode7 in United States
The page breaks are applied in two ways:
1.)Find the row with all the white pixels.
(But this selection should be efficient as we want to print in minimum no. of pages.
For example: if we get a white line on 200th row, 600th row and 900th row, we should choose 900th line to break page).
2.) If no such row exists, break on the 1000th line.
Return all the positions of the pixels where you break the page and the number of pages, so that the image can be printed in the minimum number of pages.| Report Duplicate | Flag | PURGE
Sorry I forgot to mention.
Page size is 1000 X 1000, so you have to break the N X 1000 matrix according to the mentioned conditions in 1000 X 1000 matrices.
The program should return the number of pages used to print and the position of pixels on the matrix where the page breaks were applied.
import java.util.Scanner;
public class NumberQuestion {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE, i =0;
System.out.print("Enter the numbers: ");
while(true){
i = scan.nextInt();
if(i==0)
break;
if(i%2 == 0){
if(i< min)
min = i;
}
else if(i > max)
{
max = i;
}
}
System.out.print("Min even " + min);
System.out.print("Max odd " + max);
}
}
Can someone help me with this question?
- javacode7 November 29, 2011