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

测试都没有问题但是提交一直是Wrong Answer 求助

Posted by muzifeng at 2015-04-15 21:52:10 on Problem 1007
import java.util.Scanner;

public class Main {
	
	public static int Sort(String input,int length) {
		int output = 0;
		String str[] = input.split("");
	
		for(int i = 0;i<length-1;i++) {
			for(int j = i+1;j<length;j++) {
				if(str[i].compareTo(str[j])>0){
					output++;
				}
			}
		}
		return output;
	}
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int number = sc.nextInt();
		int temp[] = new int[number];
		String str[] = new String[number];
		sc.nextLine();//吃掉换行符
		
		int big=0;//存储Sort最大值+1
		
		for(int i=0;i<number;i++) {
			str[i] = sc.nextLine();
			temp[i]=Sort(str[i],length);
		//	System.out.println(temp[i]);
			if(big<=temp[i])
				big = temp[i]+1;
		}
		System.out.println(big);
		int flag = 0;
		for(int i = 0;i<number;i++) {
			for(int j = 0;j<number;j++) {
				//选出最小的 输出,然后又big代替输出的temp[i]
				     if(temp[i]>=temp[j]&&temp[flag]>temp[j]) {
					    flag = j;
				//	 System.out.println(temp[i]+"?"+temp[j]);
			 }	
			}
			temp[flag] = big;
			System.out.println(str[flag]);
		}

	}

}

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