/* * Web Browser 2011-10-3 11:10AM Eric Zhou */import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import java.util.List;public class Main { public static void main(String[] args) throws IOException { BufferedReader cin = new BufferedReader(new InputStreamReader(System.in)); Listlist = new ArrayList (); list.add("http://www.acm.org/"); int cur = 0; while(true){ String s[] = cin.readLine().split(" "); if(s[0].compareTo("QUIT") == 0) break; if(s[0].compareTo("BACK") == 0){ if(cur > 0){ -- cur; System.out.println(list.get(cur)); }else{ System.out.println("Ignored"); } continue; } if(s[0].compareTo("FORWARD") == 0){ if(cur != list.size() - 1){ ++ cur; System.out.println(list.get(cur)); }else{ System.out.println("Ignored"); } continue; } if(s[0].compareTo("VISIT") == 0){ while(cur < list.size() - 1) list.remove(cur + 1); list.add(++ cur,s[1]); System.out.println(list.get(cur)); continue; } } }}
作者:binfeihan 发表于2011-10-3 11:40:01
阅读:212 评论:0