AnindyaBiswas

Floyd method

May 5th, 2022 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Floyd {
  3.  
  4.     static void do_floyd(int n)
  5.     {
  6.         int k=1;
  7.         for(int i=1 ; i <= n ; i++)
  8.         {
  9.             for(int j=1 ; j <= i ; j++)
  10.             {
  11.                 System.out.print(k++ +" ");
  12.                
  13.             }
  14.             System.out.println();
  15.         }
  16.     }
  17.  
  18.     public static void main(String args[])
  19.     {
  20.         Scanner sc = new Scanner(System.in);
  21.         System.out.print("Enter no of rows : ");
  22.         int n = sc.nextInt();
  23.         do_floyd(n);
  24.     }
  25. }
Add Comment
Please, Sign In to add comment