forked from akkupy/codeDump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
waveprint.java
64 lines (53 loc) · 1.16 KB
/
waveprint.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.io.*;
class waveprint {
// Function definition
static void pattern(int wave_height,
int wave_length)
{
int i, j, k, e, n, count, x;
e = 2;
x = 1;
// for loop for height
// of wave
for (i = 0; i < wave_height; i++)
{
for (j = wave_height; j <= wave_height + i; j++)
System.out.print(" ");
// for loop for wave
// length
for (count = 1; count <= wave_length; count++)
{
// checking for intermediate
// spaces
for (n = (wave_height + wave_height - 2); n >= x; n--)
System.out.print(" ");
for (k = 1; k <= e; k++)
{
if (k == 1)
System.out.print("/");
else if (k == e)
System.out.print("\\");
else
System.out.print(" ");
}
}
// incrementing counters
// value by two
x = x + 2;
e = e + 2;
System.out.println();
}
}
// Driver code
public static void main(String args[])
{
// change value to decrease or
// increase the height of wave
int wave_height = 4;
// change value to decrease or
// increase the length of wave
int wave_length = 4;
pattern(wave_height, wave_length);
}
}
// This code is contributed by Nikita Tiwari.