JAVA
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
/*
https://www.sololearn.com/discuss/3105690/triangle-wave
*/
import java.util.*;
import java.io.*;
public class Program
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// First line represents the value of N1 (frequencies of waves).
int N1 = 4; //sc.nextInt();
// Second line represents the value of N2 (amplitude of waves).
int N2 = 3; //sc.nextInt();
for(int f=1; f<=N1; f++) {
for(int a=1; a<=N2; a++) // crest
System.out.println( String.valueOf(a).repeat(a) );
for(int a=N2-1; a>=1; a--) // trough
System.out.println( String.valueOf(a).repeat(a) );
}
}
}
/*
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run