Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

check my code. codechef is giving it wrong.

$
0
0

here is my code for EASY problem---Life, the Universe, and Everything

import java.io.BufferedReader;
import java.io.InpputStreamReader;
import java.util.ArrayList;

class Life
{
    ArrayList<Integer> numbers=new ArrayList<Integer>();
    int number;

    public void readInput(BufferedReader br) throws IOException
    {
        while((number=Integer.parseInt(br.readLine()))<99)
        {
            if(number<=42)
            {
                numbers.add(number);
            }
        }

        result();
    }

    public void result()
    {
        for(int n:numbers)
        {
            System.out.println(n);
        }
    }
}

class TestLife
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Life l=new Life();
        l.readInput(br);
    }
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>