Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Peer
  • COMPETE
    • September Algorithm Challenge
    • August Cook-Off 02
    • August Algorithm Challenge
    • July Cook-Off 01
    • January Algorithm Challenge
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • About Directi
Home  » Life, the Universe, and Everything » All Submissions » Siddharth Sarasvati [176914]
0
Your rating: None
CodeChef submission 176914 (JAVA)

CodeChef submission 176914 (JAVA) plaintext list. Status: WA, problem TEST, contest . By sidz8690 (sidz8690), 2010-02-01 08:09:15.
  1. import java.io.*;
  2. import java.util.ArrayList;
  3. public class Main {
  4.  
  5. public static void main(String[] args) throws IOException {
  6. ArrayList<String> al=new ArrayList<String>();
  7. BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
  8. String str=in.readLine();
  9. al.add(str);
  10. while(!str.equals("42")) {
  11. str=in.readLine();
  12. al.add(str);
  13. if(str.equals("42")) {
  14. for(String a:al) {
  15. System.out.println("\n" +a);
  16. }}}}}

  • Login or Register to post a comment.

can someone tell me why is my

Siddharth Sarasvati - 1st Feb,2010 08:10:48.

can someone tell me why is my solution wrong ??

Should you always be adding

Stephen Merriman - 1st Feb,2010 12:27:43.

Should you always be adding the first number to al?

In fact, you shouldn't even be using an ArrayList at all, just print out the numbers when you read them.

hmm..thanks!!

Siddharth Sarasvati - 9th Feb,2010 10:32:15.

hmm..thanks!!

CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • feedback@codechef.com
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
Sponsors
The time now is: