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 1563. Bayan

Runtime error...Help please!
Posted by Gregory 23 Feb 2013 13:19
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;



public class ba9n {

    public static void array(String[] shop){
        for(int x=0;x < shop.length;x++){
            System.out.println(shop[x]);
        }
    }

    public static void arrayscanner(String[] shop) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(int x = 0;x < shop.length;x++){
            shop[x] = in.readLine();
        }
    }

    public static void task(String[] shop){
        int answer = 0;
        for(int x = 0,y = 0;x < shop.length;x++){
            if(shop[x] == "-1"){
                continue;
            }
            for(;y < shop.length;y++){

                if (x == y){
                    continue;
                }
                if (shop[x].equals(shop[y]) == true){
                    answer++;
                    shop[y] = "-1";
                }
            }
            y = 0;
        }
        System.out.println(answer);
    }

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

        int allshops = in.nextInt();
        String[] shop = new String[allshops];

        arrayscanner(shop);
        //array(shop);
        task(shop);
    }

}
Re: Runtime error...Help please!
Posted by Gregory 23 Feb 2013 13:29
In my compiller all worked good!