Skip to content

Instantly share code, notes, and snippets.

@6LYTH3
Created July 17, 2011 05:44
Show Gist options
  • Save 6LYTH3/1087240 to your computer and use it in GitHub Desktop.
Save 6LYTH3/1087240 to your computer and use it in GitHub Desktop.
Transformation
package main;
import java.util.Scanner;
import java.util.Vector;
public class M {
public static void pro() {
Scanner sc = new Scanner(System.in);
int c = 1;
while (sc.hasNext()) {
Vector<Integer> r = new Vector<Integer>();
Vector<Integer> g = new Vector<Integer>();
Vector<Integer> b = new Vector<Integer>();
Vector<Integer> count = new Vector<Integer>();
int row = sc.nextInt();
int col = sc.nextInt();
if (col == 0 && row == 0)
break;
for (int i = 0; i < (row * col); i++) {
r.add(sc.nextInt());
}
for (int i = 0; i < (row * col); i++) {
g.add(sc.nextInt());
}
for (int i = 0; i < (row * col); i++) {
b.add(sc.nextInt());
}
for (int i = 0; i < (row * col); i++) {
count.add((r.get(i) + g.get(i) + b.get(i)) / 3);
}
System.out.println("\nCase " + c++ + ":");
int k = 0;
for (int i = 0; i < (row * col); i++) {
if (k++ == col)
System.out.println("");
System.out.print(count.get(i) + ",");
}
}
}
public static void main(String[] arge) {
pro();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment