-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFind Area of Rectangle.cpp
46 lines (36 loc) · 1015 Bytes
/
Find Area of Rectangle.cpp
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
import java.util.Scanner;
public class ArraySolution1 {
public static void main(String[] args) {
int n = 5;
int arr[] = {2,3,4,5};
int newarr[] =new int[n];
int a = 0;
while(n >= 0){
newarr[a] = n;
a++;
n--;
if(n == 0){
n = 5;
break;
}
}
int missingnumber = 0 ;
int count = 0;
for (int i = 0; i < n; i++) {
//System.out.println("i - "+ i);
for (int j = 0; j < n-1; j++) {
//System.out.println("j" + j);
boolean check = newarr[i] == arr[j];
if(check){
count++;
break;
}
if(j == n-2){
missingnumber = newarr[i];
System.out.println("Missing number - " + missingnumber);
return;
}
}
}
}
}