| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:Do not print unneeded blanks at the end of ANY line.In Reply To:Do not print unneeded blanks at the end of ANY line. Posted by:YeeBoo at 2011-03-19 18:05:41 I implemented what you noted and still gives me WA. Here is my code in JAVA
import java.util.*;
public class Main{
public static void main(String[] argc){
Scanner input = new Scanner(System.in);
String[] str = new String[4];
char[] chr = new char[26];
int[] counter = new int[26];
char chr_temp;
for(String s: str){
s = input.nextLine();
for(int c = 0; c < s.length(); c++){
chr_temp = s.charAt(c);
if((chr_temp >= 'A') && (chr_temp <= 'z')){
chr[chr_temp-65] = chr_temp;
counter[chr_temp - 65]++;
}
}
}
int max = 0;
for(int i: counter){
if(i > max)
max = i;
}
int astericts =0;
int spaces = 0;
while (max > 0){
for(int i: counter){
spaces++;
if(i >= max)
astericts = spaces;
}
spaces = 0;
for(int i = 0; i < astericts; i++){
if (i == astericts -1)
System.out.print("*\n");
else if(counter[i] >= max)
System.out.print("* ");
else System.out.print(" ");
}
max--;
}
for(char c: chr){
if(c == chr[25])
System.out.print(c+ "\n");
else System.out.print(c +" ");
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator