All pastes #32665 Raw Edit

jojo

public java v1 · immutable
#32665 ·published 2005-12-06 15:40 UTC
rendered paste body
package p1;import java.io.*;public class Matrica {    public static void main(String[] args) throws IOException {      BufferedReader ds = new BufferedReader(new InputStreamReader(System.in));      System.out.println("Iveskite n");      int n = Integer.parseInt(ds.readLine());      System.out.println("Iveskite m");      int m = Integer.parseInt(ds.readLine());      double a[][] = new double[n][m];      Metodai veiksmai = new Metodai();      veiksmai.skaitoIrasa(ds, a, n, m);      veiksmai.spausdinti(a, n, m);      System.out.println();      veiksmai.rastiMaxIrSukeisti(a, n, m);      veiksmai.spausdinti(a, n, m);    }}class Metodai{    void skaitoIrasa(BufferedReader ds, double a[][], int m, int n) throws        IOException {      for (int i = 0; i < n; i++) {        System.out.println("Iveskite eilutes " + i + " elementus");        for (int j = 0; j < m; j++)          a[i][j] = Double.parseDouble(ds.readLine());      }    }      void spausdinti(double a[][], int n, int m)    {      for (int i = 0; i < n; i++)         {          for (int j = 0; j < m; j++)            System.out.print(a[i][j] + "  ");          System.out.println();        }      }      void rastiMaxIrSukeisti(double a[][], double n, double m) {            int ind;        for (int j = 0; j < m; j++) {          double max = a[0][j];          ind = 0;          for (int i = 0; i < n; i++)            if (max < a[i][j]) {              max = a[i][j];              ind = i;            }          a[ind][j] = a[0][j];          a[0][j] = max;          }      }}