class CountFills31b {
public static void main(String args[]) {
int c[][] = { {0,0,0,0,0,0,0,0,0,0}, {0,1,1,1,1,1,1,1,1,0}, {0,0,0,0,0,0,0,1,0,0}, {0,0,1,1,1,1,0,1,0,0}, {0,0,1,0,0,1,0,1,0,0}, {0,0,1,1,1,1,0,1,0,0}, {0,0,0,0,0,0,0,1,0,0}, {0,0,0,0,0,0,1,1,0,0}, {0,0,0,0,0,0,0,1,0,0}, {0,0,0,0,0,0,0,0,0,0} }; int xZeroCount[] = new int[10]; int yZeroCount[] = new int[10]; int xNextOneCount[] = new int[10]; int yNextOneCount[] = new int[10]; int xNextZeroCount[] = new int[10]; int yNextZeroCount[] = new int[10]; int xZeroOneCount[] = new int[10]; int yZeroOneCount[] = new int[10]; int ZeroOrOne; int i; int x,y;
for( y = 0; y < 10; y++ ) {
xZeroCount[y] = 0;
x = 0;
while( x < 10 && c[y][x] == 0 ) {
xZeroCount[y] = xZeroCount[y] + 1;
x++;
}
xNextOneCount[y] = 0; while( x < 10 && c[y][x] == 1 ) { xNextOneCount[y] = xNextOneCount[y] + 1; x++; } xNextZeroCount[y] = 0; while( x < 10 && c[y][x] == 0 ) { xNextZeroCount[y] = xNextZeroCount[y] + 1; x++; }
}
for( y = 0; y < 10; y++) {
x = 0;
i = 0;
ZeroOrOne = 1;
while( i <= 10 ) {
xZeroOneCount[y][i] = 0;
if( ZeroOrOne == 0 ) {
ZeroOrOne = 1;
} else {
ZeroOrOne = 0;
}
while( x < 10 && c[y][x] == ZeroOrOne ) {
xZeroOneCount[y][i] = xZeroOneCount[y][i] + 1;
x++;
}
i++;
}
}
for( x = 0; x < 10; x++ ) { yZeroCount[x] = 0; y = 0; while( y < 10 && c[y][x] == 0 ) { yZeroCount[x] = yZeroCount[x] + 1; y++; }
yNextOneCount[x] = 0;
while( y < 10 && c[y][x] == 1 ) {
yNextOneCount[x] = yNextOneCount[x] + 1;
y++;
}
yNextZeroCount[x] = 0;
while( y < 10 && c[y][x] == 0 ) {
yNextZeroCount[x] = yNextZeroCount[x] + 1;
y++;
}
yZeroOneCount[x] = 0;
while( y < 10 && c[y][x] == 1 ) {
yZeroOneCount[x] = yZeroOneCount[x] + 1;
y++;
}
}
for( y = 0; y < 10; y++ ) { for( x = 0; x < 10; x++ ) { System.out.print("" + c[y][x] + " "); } System.out.print(" || " + xZeroCount[y]); System.out.print("," + xNextOneCount[y]);
System.out.print("," + xNextZeroCount[y]);
System.out.print("," + xZeroOneCount[y]);
System.out.print("\n");
}
System.out.print("-------------------------\n");
for( x = 0; x < 10; x++ ) {
System.out.print("" + yZeroCount[x] + " ");
}
System.out.print("\n");
for( x = 0; x < 10; x++ ) {
System.out.print("" + yNextOneCount[x] + " ");
}
System.out.print("\n");
for( x = 0; x < 10; x++ ) {
System.out.print("" + yNextZeroCount[x] + " ");
}
System.out.print("\n");
for( x = 0; x < 10; x++ ) {
System.out.print("" + yZeroOneCount[x] + " ");
}
System.out.print("\n");
}
}
回答1件
あなたの回答
tips
プレビュー