import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int sum = 0;
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[100];
int[] b = new int[100];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
sum += a[i];
b[a[i]]++;
}
int num = 0;
for (int i = 0; i < n; i++) {
if (b[i] > 1)
num++;
}
System.out.println(sum);
System.out.println(num);
}
}
输入n个数,统计相同元素个数以及所有元素的和。【无标题】
于 2023-07-03 19:21:16 首次发布