#6433: JAVA:在我的電腦執行是正確的


wemee (阿勇)

學校 : 國立北港高級中學
編號 : 4621
來源 : [220.135.3.103]
最後登入時間 :
2023-09-27 11:01:07
d518. 文字抄寫 II | From: [114.32.48.233] | 發表日期 : 2012-03-04 22:06

在我的電腦執行範例測資是正確的

可是放上去卻是:RE(產生立即停止符號)

請問純粹是我的JAVA版本有些用法

在伺服器上面的無法執行嗎?

我用的SDK是剛下載的JAVA 1.7

import java.util.HashMap;
import java.util.Scanner;

public class JAVA {

    static HashMap<String, Integer> hm;
    
    static{
        hm = new HashMap<String, Integer>();
    }
    
    public static void main(String[] args) {
        Scanner jin = new Scanner(System.in);
        int n,index;
        String s = "";
        
        while (jin.hasNext()) {
            n=Integer.parseInt(jin.nextLine());
            hm.clear();
            index = 0;
            
            for(int i=0; i<n; i++){
                s = jin.nextLine();
                
                if(hm.containsKey(s)){
                    System.out.println("Old! " + hm.get(s));
                }else{
                    System.out.println("New! " + ++index);
                    hm.put(s, index);
                }
            }
        }
    }
}

 
ZeroJudge Forum