Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication2;
- import java.io.*;
- import java.util.Random;
- public class JavaApplication2 {
- public static void main(String[] args) throws IOException {
- BufferedReader pobranie=new BufferedReader(new FileReader("dane.txt"));
- BufferedWriter zapis=new BufferedWriter(new FileWriter("wynik.txt"));
- String a=pobranie.readLine();
- String b=pobranie.readLine();
- int w,k,max=0,sumac,x,y;
- w=Integer.parseInt(a);
- k=Integer.parseInt(b);
- int[][] tab = new int[w][k];
- Random r=new Random();
- for (int i=0;i<w;i++)
- {
- for (int j=0;j<k;j++)
- {
- if (i==0||j==0 || i==w-1||j==k-1)
- {
- tab[i][j]=r.nextInt(90)+10;
- if (tab[i][j]>max)
- {
- max=tab[i][j];
- }
- }
- else
- {
- tab[i][j]=r.nextInt(10);
- }
- zapis.write(tab[i][j]+" ");
- }
- zapis.write("\n");
- }
- x=max%10;
- y=max/10;
- sumac=y+x;
- System.out.print(max+" "+sumac);
- zapis.close();
- pobranie.close();
- }
- }
RAW Paste Data