Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么老是runtime error,请教一下,快疯了

Posted by JLK at 2006-02-07 16:57:02 on Problem 1028
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)throws Exception
    {
        List list = new ArrayList();
        list.add("http://www.acm.org/");
        int pointer = 0;
        while(true)
        {
            Scanner cin=new Scanner(System.in);
            String str = cin.nextLine().trim();
            if(str.equals("QUIT"))
            {
                return;
            }
            if(str.equals("BACK"))
            {
                if(pointer==0)
                {
                    System.out.println("Ignored");
                }
                else
                {
                    pointer--;
                    System.out.println(list.get(pointer));
                }
            }
            if(str.equals("FORWARD"))
            {
                if(pointer==list.size()-1)
                {
                    System.out.println("Ignored");
                }
                else
                {
                    pointer++;
                    System.out.println(list.get(pointer));
                }
            }
            if(str.startsWith("VISIT"))
            {
                String[] s = str.split(" ");
                list.add(++pointer,s[1]);
                System.out.println(s[1]);
            }

        }
    }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator