-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLucky.java
More file actions
36 lines (36 loc) · 852 Bytes
/
Copy pathLucky.java
File metadata and controls
36 lines (36 loc) · 852 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
import java.util.*;
class Lucky
{
public static void main(int s)
{
int a[]=new int[s],c=1,b[]=new int[s];
Scanner sc=new Scanner(System.in);
for(int i=0;i<a.length;i++)
{ System.out.print("Enter the element");
a[i]=sc.nextInt();
}
while(c<a.length)
{
int k=0,d=0;
for(int i=0;i<a.length-c;i=i+c+1)
{
a[i+c]=0;
k++;
}
c++;
b=new int[a.length-k];
for(int i=0;i<a.length;i++)
{
if(a[i]==0)
continue;
else
b[d++]=a[i];
}
a=b;
}
for(int i=0;i<a.length;i++)
{
System.out.print(a[i]+",");
}
}
}