Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import java.util.ArrayList;
- import java.io.InputStream;
- import java.nio.file.Path;
- import java.io.File;
- import java.io.*;
- public class Main {
- public static String str;
- public static int HEIGHT;
- public static int WIDTH;
- public static int[] tor;
- public static int[][] matrix;
- public static boolean[][] labirint;
- public static void main(String[] args) {
- Path p = Paths.get("C:\\Users\\acer\\IdeaProjects\\Lobe\\src\\com\\company\\Input");
- InputStream in;
- try{
- in = Files.newInputStream(p);
- byte[] bytes = new byte[in.available()];
- in.read(bytes);
- String s = new String(bytes, "cp1251");
- str = s;
- }
- catch (Exception e){
- return;
- }
- String lolo = str.replaceAll("\\p{Cntrl}", ",");
- String help = lolo.replaceAll(" ", ";");
- String d = help.replaceAll(",,", ";");
- String[] s = d.split(";");
- tor = new int[s.length];
- int c = 0;
- for (String i: s){
- tor[c] = Integer.parseInt(i);
- c++;
- }
- HEIGHT = tor[0];
- WIDTH = tor [1];
- matrix = new int[HEIGHT][WIDTH];
- int yo = 2;
- for (int i=0; i<HEIGHT; i++){
- for (int j=0; j<WIDTH; j++){
- matrix[i][j] = tor[yo];
- yo++;
- }
- }
- for (int i = 0; i<HEIGHT; i++){
- for (int j = 0; j<WIDTH; j++){
- System.out.print(matrix[i][j]);
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement