解题思路:
注意事项:
参考代码:
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语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:787 |
数对 (C语言代码)浏览:702 |
C二级辅导-温度转换 (C语言代码)浏览:732 |
矩阵的对角线之和 (C语言代码)浏览:1356 |
1197求助浏览:631 |
C语言训练-字符串正反连接 (C语言代码)浏览:632 |
小O的乘积 (C++代码)浏览:520 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:3359 |
Manchester- A+B for Input-Output Practice (VII)浏览:1014 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:881 |