3
I wanted to add to linhaPreta
the number of lines with only 0, and the linhaBranca
only with 1.
public class Pixel {
public static void main(String[] args) {
int[][] img = {
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 0, 1, 0, 1, 1, 1, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 1, 0, 0, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0 },};
int ppreto = 0;
int pbranco = 0;
int linhaPreta = 0;
int linhaBranca = 0;
int i;
int j = 0;
for (i = 0; i < img.length; i++) {
for (j = 0; j < img[i].length; j++) {
if (img[i][j] == 0) {
ppreto++;
}
if (img[i][j] == 1) {
pbranco++;
}
if (img[i].length == 0) {
linhaPreta++;
}
if (img[i].length == 0) {
linhaBranca++;
}
}
}
System.out.print("qtde ponto preto = " + ppreto + "\n");
System.out.print("qtde ponto branco = " + pbranco + "\n");
System.out.print("Qtd linha preta = " + linhaPreta + "\n");
System.out.print("Qtd linha branca= " + linhaBranca + "\n");
}
}
You could use crase, help understand better... Give a read on the question, there is no way to understand if it is to be added or added to this...
– HiHello