Created
July 17, 2011 03:40
-
-
Save wingyplus/1087127 to your computer and use it in GitHub Desktop.
Gweans3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Main; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.util.Scanner; | |
public class ImageTransformation { | |
public static void main(String[] args) { | |
File file = new File("case.in"); | |
Scanner sc; | |
try { | |
sc = new Scanner(file); | |
int c = 1; | |
while(true) { | |
int x = sc.nextInt(); | |
int y = sc.nextInt(); | |
if (x == 0 && y == 0) break; | |
int[][][] R = new int[3][x][y]; | |
int[][] sum = new int[x][y]; | |
for(int r = 0; r < 3; r++) { | |
for(int i = 0; i < x; i++) { | |
for(int j = 0; j < y; j++) { | |
R[r][i][j] = sc.nextInt(); | |
sum[i][j] += R[r][i][j]; | |
} | |
} | |
} | |
System.out.println("Case " + c++ + ":"); | |
for(int i = 0; i < x; i++) { | |
for(int j = 0; j < y; j++) { | |
sum[i][j] = sum[i][j]/3; | |
System.out.print(sum[i][j] + " "); | |
} | |
System.out.println(); | |
} | |
} | |
} catch (FileNotFoundException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Main; | |
import java.util.Scanner; | |
public class MatrixSearching { | |
public static void matrixS(int[][] mat, int[] rc) { | |
int min = mat[0][0]; | |
for(int i = rc[0] - 1; i <= rc[2] - 1; i++) { | |
for(int j = rc[1] - 1; j <= rc[3] - 1; j++) { | |
if (mat[i][j] < min) min = mat[i][j]; | |
} | |
} | |
System.out.println(min); | |
} | |
public static void main(String[] args) { | |
Scanner s = new Scanner (System.in); | |
int tc = s.nextInt(); | |
int n = s.nextInt(); | |
int[][] mat = new int [n][n]; | |
for (int round = 1; round <= tc; round++) { | |
for(int i = 0; i < n; i++) { | |
for(int j = 0; j < n; j++) { | |
mat[i][j] = s.nextInt(); | |
} | |
} | |
int line = s.nextInt(); | |
for(int j = 1; j <= line; j++) { | |
int[] rc = {s.nextInt(), s.nextInt(), s.nextInt(), s.nextInt()}; // r1, c1, r2, c2 0, 1, 2, 3 | |
matrixS(mat, rc); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment