View Code of Problem 17

package shuzu;

import java.util.Scanner;

public class shuzu {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int a [][] = new int[n][m];
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<m;j++) {
				a[i][j] = scanner.nextInt();
			}
		}
		int [] T = new int[m];
		for(int i = 0;i<n;i++) {
			for (int j = 0; j < m-1; j++) {
				int temp;
				if(a[i][j]<a[i][j+1]) {
					temp = a[i][j];
					a[i][j] = a[i][j+1];
					a[i][j+1] = temp;
				}
			}
		}
		for(int i = 0;i<a.length-1;i++) {
			int temp;
			if (a[i][0]<a[i+1][0]) {
				temp = a[i][0];
				a[i][0] = a[i+1][0];
				a[i+1][0] = temp;
			}
		}
		System.out.println(a[0][0]);
	}

}

/*
Main.java:5: error: class shuzu is public, should be declared in a file named shuzu.java
public class shuzu {
       ^
1 error
*/

Double click to view unformatted code.


Back to problem 17