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 1585. Penguins

Why crashing?
Posted by Manikandan 28 Mar 2011 15:22
import java.io.*;
import java.util.Scanner;
public class string {
    public static void main(String args[]) throws IOException
    {
        Scanner sc = new Scanner(System.in);
        BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
        String each;
        int m=0,l=0,e=0;
        int num = sc.nextInt();
        for(int i=0;i<num;i++)
        {
            each = bufferedreader.readLine();
            if(each.charAt(0)=='M')
            {
                m++;
            }
            else if(each.charAt(0)=='L')
            {
                l++;
            }
            else if(each.charAt(0)=='E')
            {
                e++;
            }
        }
        if((m>=l) && (m>=e))
            System.out.println("Macaroni Penguin");
        if((l>=m) && (l>=e))
            System.out.println("Little Penguin");
        if((e>=m) && (e>=l))
            System.out.println("Emperor Penguin");

    }
Re: Why crashing?
Posted by Nodir NAZAROV Komiljonovich 5 Sep 2012 12:21
Same question, maybe related with BufferedReader.
Several times faced with this problem, any idea?