forked from VipWangQiaoqiao/leetcode-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(贝壳笔试)
43 lines (29 loc) · 887 Bytes
/
(贝壳笔试)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int m = scanner.nextInt();
int[] ints = new int[m];
for (int i = 0; i < m; i++) {
ints[i] = scanner.nextInt();
}
int num = 0;
for (int n = 0; n < ints.length; n++) {
int flag = 0;
for (int i = 0; i < ints.length; i++) {
if (i == n) continue;
for (int j = i + 1; j < ints.length; j++) {
if (j == n) continue;
int sum = ints[i] + ints[j];
if (sum == ints[n]) {
flag = 1;
}
}
}
if(flag == 1){
num++;
}
}
System.out.println(num);
}
}