ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1370. Magician

Runtime error in Java 1.7 test 2 help me please
Posted by Axmadjon 5 May 2014 14:50
import java.util.Scanner;

public class _1370 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int digitos = in.nextInt();
        int cliques = in.nextInt();
        String saida = "";
        String parte2 = "";

        for (int i = 1; i <= cliques; i++){
            saida += in.nextInt();
        }

        for (int i = cliques+1; i <= digitos; i ++){
            parte2 += in.nextInt();
        }

        parte2 += saida;

        System.out.println( parte2.substring(0,10) );
    }
}
Re: Runtime error in Java 1.7 test 2 help me please
Posted by Sahadev 14 Jul 2015 22:30
you are using in.nextInt() to get the input from the user for a String. That is used for integers. You should be using in.next() or in.nextLine() for String.