- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnake.java
More file actions
Latest commit
43 lines (39 loc) · 502 Bytes
/
Copy pathSnake.java
File metadata and controls
43 lines (39 loc) · 502 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
37
38
39
40
41
42
43
classSnake
{
publicstaticvoidmain(String[] args)
{
intn = 5;
intk = 1;
for (inti=0;i<n ;i++ )
{
intl=0;
if (i%2==0)
{
k=k+i;
}
else
{
l = k+i;
}
for (intj=0;j<n ;j++ )
{
if(i>=j)
{
if(i%2==0)
{
System.out.print(k++);
}
else
{
System.out.print(l--);
}
}
else
{
System.out.print(" ");
}
}
System.out.println();
}
}
}