|
|
back to boardHow can my program get AC even it returns wrong answer for the first test? Hello, How can my program get AC even it returns wrong answer for the first test? import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter;
public class SandrosBook {
public static void main(String args[]) throws IOException{
InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); PrintWriter out=new PrintWriter(System.out);
int[] a=new int[26];
String s=br.readLine(); int i=1; int start=0,end=0; start=s.charAt(0)-97; int max=0;
while(i<s.length()){ char c=s.charAt(i); a[(int)c-97]++; i++; }
int k=0; for(int ii=0;ii<26;ii++){ if(a[ii]>max) { max=a[ii]; k=ii; } }
k=k+97;
System.out.println((char)k); out.flush(); }
} Re: How can my program get AC even it returns wrong answer for the first test? try test: b right answer "b", but you output "a" Edited by author 09.03.2012 14:09 Re: How can my program get AC even it returns wrong answer for the first test? my son fail |
|
|