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

求大佬看看哪里错了,我在自己编译器上运行没撒问题

Posted by a123381246 at 2018-12-20 20:48:46 on Problem 1002
package Lesson3;

import java.util.Arrays;
import java.util.Scanner;

public class TeleMap {
	int len;
	String[] s;
	int[] m;
	int num,count;
	String out="";

	public static void main(String[] args) throws Exception {
		TeleMap tm = new TeleMap();
		tm.info();
		tm.count();
		tm.output();

	}

	private void output() {
		if(flag!="") {
		// TODO Auto-generated method stub
		System.out.println(out);}
		else {
			System.out.println("No duplicates."); 
		}
	}

	private void count() {
		num = 0;
		count=1;
		// TODO Auto-generated method stub
		for (int i = 1; i < len; i++) {
			if(m[i]==m[i-1]) {
				count++;
			}
			else if(count>1) {
				out+="\n"+format(m[i-1])+" "+count;
				count=1;
			}
		}
	}

	private String format(int temp) {
		System.out.println(temp);
		int a=temp;
		int b=temp;
	    String temp_s="";
		for(int i=6;i>=0;i--) {
//			System.out.println((int)Math.pow(10, i));
			a=b/((int)Math.pow(10,i));
			temp_s+=a;
			if(i==4) {
				temp_s+="-";
			}
			b-=a*((int)Math.pow(10,i));
//			System.out.println(" a:  "+a);
		}
		// TODO Auto-generated method stub
		return temp_s;
	}

	void info() throws Exception {
		Scanner sc = new Scanner(System.in);
		len = sc.nextInt();
		s = new String[len];
		m = new int[len];
		for (int i = 0; i < len; i++) {
			s[i]=sc.next();
			s[i] = s[i].replaceAll("-", "");
			s[i] = s[i].replaceAll("[ABC]", "2");
			s[i] = s[i].replaceAll("[DEF]", "3");
			s[i] = s[i].replaceAll("[GHI]", "4");
			s[i] = s[i].replaceAll("[JKL]", "5");
			s[i] = s[i].replaceAll("[MNO]", "6");
			s[i] = s[i].replaceAll("[PRS]", "7");
			s[i] = s[i].replaceAll("[TUV]", "8");
			s[i] = s[i].replaceAll("[WXY]", "9");
			m[i] = Integer.parseInt(s[i]);
		}
		Arrays.sort(m);
	}
}

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