Java编程挑战:根据论文作者顺序分配奖学金加分并按字典序输出作者总分
解析:首先需要根据输入的论文数量n,然后循环n次,每次循环中根据输入的作者数和字符串,计算每个作者的加分总数,并将作者和加分总数存储在一个列表中。最后对列表进行排序,按照字典序从小到大输出每一名作者以及其对应的加分总数。
代码如下:
```java
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
List<String> authors = new ArrayList<>();
for (int i = 0; i < n; i++) {
int authorNum = sc.nextInt();
String[] names = new String[authorNum];
for (int j = 0; j < authorNum; j++) {
names[j] = sc.next();
}
for (int j = 0; j < authorNum; j++) {
if (j == 0) {
authors.add(names[j] + " " + (3 * (1 << (25 - names[j].length()))));
} else if (j == 1) {
authors.add(names[j] + " " + (2 * (1 << (25 - names[j].length()))));
} else {
authors.add(names[j] + " " + (1 * (1 << (25 - names[j].length()))));
}
}
}
Collections.sort(authors);
for (String author : authors) {
System.out.println(author);
}
}
}
```
免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。