inverted floyd triangle in java

Solutions on MaxInterview for inverted floyd triangle in java by the best coders in the world

showing results for - "inverted floyd triangle in java"
Erik
08 May 2020
1// Inverted floyd triangle in java
2import java.util.Scanner;
3public class InvertedFloydTriangleDemo
4{
5   public static void main(String[] args) 
6   {
7      Scanner sc = new Scanner(System.in);
8      System.out.print("Please enter size limit: ");
9      int num = sc.nextInt();
10      int a, b, x = 0;
11      System.out.println("Here's Inverted Floyd Triangle: ");
12      for(a = 1; a <= num; a++)
13      {
14         for(b = 1; b <= a; b++)
15            x++;
16      }
17      for(a = num; a >= 1; a--)
18      {
19         for(b = 1; b <= a; b++)
20         {
21            System.out.print(x + " ");
22            x--;
23         }
24         System.out.println();
25      }
26      sc.close();
27   }
28}