-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathINCARRAY.java
More file actions
35 lines (31 loc) · 743 Bytes
/
INCARRAY.java
File metadata and controls
35 lines (31 loc) · 743 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
package lecture4;
import java.util.Scanner;
// NOT WORKING
public class INCARRAY {
static Scanner s = new Scanner(System.in);
public static void main(String[] args) {
int[] arr = takeinput() ;
int m = s.nextInt();
while(m>=0) {
int a= s.nextInt();
int b = s.nextInt();
int k = s.nextInt();
increment(arr ,a,b,k );
m--;}
}
public static int[] takeinput() {
int[] array;
System.out.println(" enter size ");
int n = s.nextInt();
array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = s.nextInt();
}
return array;
}
public static void increment(int[] arr , int a , int b , int k) {
for(int i=a ; i<=b ; i++) {
arr[i]+= k ;
}
}
}