BBBeaute 2016-08-04 10:51 采纳率: 0%
浏览 1062

小白一名,请教 poj1013 问题

下面是我的代码,提交后显示回答错误,请大神指明.

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static String l1 = null;
    static String r1 = null;
    static Set<String> tList = new HashSet<String>();//真币
    static Set<String> lList = new HashSet<String>();//有轻假币嫌疑
    static Set<String> wList = new HashSet<String>();//有重假币嫌疑
    private static void even(){
            int l =l1.length();
            String[] le = l1.split("");
            String[] re = r1.split("");
            for(int i = 0 ; i <l ; i++){
                tList.add(le[i+1]);
                tList.add(re[i+1]);
            }   
    }
    private static void up(){

        int l = l1.length();
        String[] le = l1.split("");
        String[] re = r1.split("");
        for(int i = 0 ; i <l ; i++){
            wList.add(le[i+1]);
            lList.add(re[i+1]);
        }
    }
    private static void down(){ 
        int l = l1.length();
        String[] le = l1.split("");
        String[] re = r1.split("");
        for(int i = 0 ; i <l ; i++){
            lList.add(le[i+1]);
            wList.add(re[i+1]);
        }
    }
    public static void main(String[] args) {
        Scanner sca = new Scanner(System.in);
        int count = sca.nextInt(); // 输入判断次数
        for(int x = 0 ; x < count ; x++){
            lList.clear();
            wList.clear();
            tList.clear();
            for(int i = 0 ; i <3 ; i++){
                l1 = sca.next();
                r1 = sca.next();
                String f1 = sca.next();
                sca.nextLine();
                if(f1.equals("even")){
                    even();
                }else if (f1.equals("down")){
                    down();
                }else{
                     up();
                }
            }
            wList.removeAll(tList);
            lList.removeAll(tList);
            if(lList.size() != 0){
                 lList.removeAll(tList);
                 for( String s : lList){
                     System.out.println(s+" is the counterfeit coin and it is light. ");
                 }
            }
            if(wList.size() != 0){
                 wList.removeAll(tList);
                 for( String s : wList){
                     System.out.println(s+" is the counterfeit coin and it is  heavy. ");
                 }
            }
        }
        sca.close();
    }
}
  • 写回答

2条回答 默认 最新

  • threenewbee 2016-08-04 11:00
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导