Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求大牛改正Java代码! 本人属新手,望得到指点!(runtime error)import java.util.Scanner ; public class poj1028{ static String str[] = new String[100] ; static int i = 1 ; public static void main(String args[]){ for(int x=0; x<100; x++) str[x] = null ; str [1] = "http://www.acm.org/" ; Scanner sc = new Scanner(System.in) ; for(;;){ String demo = sc.nextLine() ; char d = demo.charAt(0) ; switch (d){ case 'V':{ visit() ; break ; } case 'B':{ back() ; break ; } case 'F':{ forward() ; break ; } case 'Q':{ System.exit(1) ; break ; } } } } static void visit(){ Scanner sc = new Scanner(System.in) ; i ++ ; str[i] = sc.nextLine() ; System.out.println(str[i]) ; } static void back(){ i -- ; if(str[i]==null){ System.out.println("Ignored") ; i ++ ; } else System.out.println(str[i]) ; } static void forward(){ i ++ ; if(str[i]==null){ System.out.println("Ignored") ; i -- ; } else System.out.println(str[i]) ; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator