-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise.java
More file actions
72 lines (64 loc) · 1.76 KB
/
Exercise.java
File metadata and controls
72 lines (64 loc) · 1.76 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package array;
/**
* @ClassName Exercise
* @Description
* @Author changxuan
* @Date 2020-03-11 21:44
**/
public class Exercise {
public static void main(String[] args){
int[][] number = new int[][]{};
// System.out.println(number.length);
// int n = 0;
// for (int i = 0; i < 3; i++){
// for (int j = 0; j < 4; j++){
// number[i][j] = (n++);
// }
// }
System.out.println(number.length-1);
//System.out.println(number[0].length);
System.out.println(Find(7,number));
User userA = new User();
userA.name = "test";
userA.age = 9;
User userC = new User();
userC.name = "test";
userC.age = 10;
System.out.println(userA.toString());
User userB = userA;
System.out.println(userB.toString());
userA = userC;
System.out.println(userA);
System.out.println(userB.toString());
}
public static boolean Find(int target, int [][] array) {
int r_length = array.length-1;
if (r_length < 0){
return false;
}
int c_length = array[0].length-1;
if (target<array[0][0] || target>array[r_length][c_length]){
return false;
}
for(int r = 0; r <= r_length; r++){
for(int c = c_length; c >= 0; c--){
if(target < array[r][c]){
continue;
}else if(target > array[r][c]){
break;
}else{
return true;
}
}
}
return false;
}
}
class User{
public String name;
public Integer age;
@Override
public String toString() {
return super.toString();
}
}