# 一个计算题的代码实现

0

AA权重为2*1

0

package test2;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
// System.out.println(str);
String[] ss = str.split(";");
int x = js(ss);
System.out.println(x);
}

public static int js(String[] str) {
//权重
int qz = 0;
int max = 0;
int[] test = new int[4];
for (int i = 0; i < str.length; i++) {
if (str[i].equals("A")) {
test[0]++;
} else if (str[i].equals("AA")) {
test[1]++;
} else if (str[i].equals("AAA")) {
test[2]++;
} else if (str[i].equals("AAAA")) {
test[3]++;
}
}
for (int i = 0; i < test.length; i++) {
if (test[i] > max){
qz = i+1;
max = test[i];}
}
//System.out.println("qz:" + qz+",maxNum:"+max);

return max * qz;
}

}

0

'A;AA;AAA;AAAA;AA;AA'.split(';').sort().reverse()[0].length * 'A;AA;AAA;AAAA;AA;AA'.split(';').length

0

`  int n="A;AA;AAA;AAAA;AA;AA".Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Max().Length *"A;AA;AAA;AAAA;AA;AA".Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Count();`

//别告诉我我是对的！

0

.net?sql?

您需要登录以后才能回答，未注册用户请先注册