-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunAround.java
More file actions
40 lines (39 loc) · 1.04 KB
/
runAround.java
File metadata and controls
40 lines (39 loc) · 1.04 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
package Ishank;
import java.util.Scanner;
public class runAround {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter length of array");
int n=sc.nextInt(), d=1, i=0, e=0, a=0;
int arr[]=new int[n];
int q[]=new int[n];
System.out.println("Enter the numbers one by one");
for(i=0;i<n;i++){
arr[i]=sc.nextInt();
}
int c=arr[0];
for(i=0;i<n;i++){
for(int x=0;x<c;x++){
if(d>=n)
d=0;
e=arr[d];
d++;
}
q[i]=d-1;
c=e;
}
for(i=0;i<n;i++){
for(int x=0;x<n;x++){
if(q[i]==q[x])
a++;
}
if(a>1){
System.out.println("Not a run around");
break;
}
a=0;
}
if(i==n)
System.out.println("Run around");
}
}