G
G
genbachae2020-02-24 07:38:59
Java
genbachae, 2020-02-24 07:38:59

Why is there an error at runtime?

There is a code that, when run in IDEA, does not give any errors:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Zad3 {
    private static int count_mass = 11;                                               //  Длина считываемого числа

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = Integer.parseInt(br.readLine());

        int size;
        byte o_el[] = new byte[] {11,11,11,11,11,10};       //  предыдущее считанное значение
        for (int i = 1; i <= count; i++){
            byte el[] = new byte[count_mass];
            size = System.in.read(el);
            if(!eq_mass(el, o_el)){
                System.out.write(el,0,size);
                o_el = el;
            }
        }
        br.close();
    }

    //  Блок функций ------------------------------


    static boolean eq_mass(byte[] m1, byte[] m2){                                   //  Сравнить массив
        boolean rez = true;                                                         //  по умолчанию массивы равны
        for (int i = 0; i < count_mass; i++) {
            if(m1[i] != m2[i]){
                rez = false;
            }
            if (m1[i] == 10 || m2[i] == 10){
                break;
            }
        }
        return rez;
    }
}


If the code is run in the system: https://contest.yandex.ru/contest/8458/problems/C
then it will give a RE (runtime error), what is causing this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question