解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while(input.hasNext()){
String str=input.nextLine();
String a[]=str.split("\\.");
String b[][]=new String[300][300];
for (int i =0; i<a.length; i++) {
b[i]=a[i].split(" ");
}
int count=0;
String c[]=new String[300];
int k[]=new int[300],max=0;
for (int i = 0; i <a.length; i++) {
for (int j = 0; j < b[i].length; j++) {
String ca=b[i][j].trim();
if(ca.contains(","))ca=ca.substring(0, ca.length()-1);
if(ca.equals(""))continue;
ca=ca.toUpperCase();
int m=check(ca,c);
if(m==-1){
c[count]=ca;
if(ca.length()>max)max=ca.length();
k[count]=1;
count++;
}
else{
k[m]++;
}
}
}
for (int i = 0; i < count; i++) {
for (int j = 0; j <max-c[i].length(); j++) {
System.out.print(" ");
}
System.out.print(c[i]+":");
for (int j = 0; j <k[i]; j++) {
System.out.print("*");
}
System.out.println(k[i]);
}
}
}
private static int check(String s, String[] c) {
for (int i = 0; i <c.length; i++) {
if(s.equals(c[i])){
return i;
}
}
return -1;
}
}
0.0分
0 人评分
兰顿蚂蚁 (C++代码)浏览:1110 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:379 |
C语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:917 |
母牛的故事 (C语言代码)浏览:716 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:559 |
DNA (C语言代码)浏览:395 |
字符串的输入输出处理 (C语言代码)浏览:1017 |
1134题解(求分析)浏览:729 |
数列排序 (C语言代码)浏览:617 |
简单的a+b (C语言代码)浏览:462 |