This question requires you to output an isosceles triangle composed of numbers on the console.
The specific steps are:
- First use the natural numbers 1, 2, 3,… to create a long enough string
- Use this string to fill the three sides of the triangle . Starting from the top vertex, fill counterclockwise.
For example, when the height of the triangle is 8:
Input, a positive integer n( 3<n<300), represents the height of the triangle
Output, an isosceles triangle filled with numbers.
In order to facilitate evaluation, we require that spaces be replaced with “.”.
Input
an integer
Output
an isosceles triangle
Code:
import java.util.Scanner;public class Main { static Scanner sc = new Scanner(System.in)