Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

right triangle star pattern in java

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		//your code here
        //      #
        //     ##
        //    ###
        //   ####
        //  #####
      Scanner scan = new Scanner(System.in);
      int c = scan.nextInt();

      for(var i=0; i<c;i++)
      {
        var t =0;
        while(t!=c-i-1)
        {
          System.out.print(" ");
          t++;
        }
        var k =i+1;
        for(var j=0; j<k;j++)
          System.out.print("#");
        System.out.print("
");
      }
	}
}
Comment

Right triangle star pattern in java

class rightTrianlge {
  public static void main(String[] args) {

    // size of the triangle
    int size = 5;
    // loop to print the pattern
    for (int i = 0; i < size; i++) {
      // print spaces
      for (int j = 1; j < size - i; j++) {
        System.out.print(" ");
      }
      // print stars
      for (int k = 0; k <= i; k++) {
        System.out.print("*");
      }
      System.out.println();
    }
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java break multiple loops 
Java :: java remove last character 
Java :: radio button java swing 
Java :: java replaceAll ignore case 
Java :: java string regexp replace 
Java :: how to instance a calendar in java 
Java :: java read next line 
Java :: for loop javasctip 
Java :: abstract class in java 
Java :: How to efficiently convert a sorted array into a min height binary search tree, in Java? 
Java :: viewpager androidx dependencies 
Java :: fill two dimensional array columns by columns java 
Java :: how to remove null values collections 
Java :: how to change double to int in java 
Java :: testing the web layer without authentication spring 
Java :: integer.tostring java 
Java :: spigot dispatchcommand 
Java :: java clone matrix 
Java :: car class java 
Java :: create array of particular length in java 
Java :: java throw keyword 
Java :: java.lang.object[4] 
Java :: camera permission in android 
Java :: boucle for avec un tableau java 
Java :: java basic syntax 
Java :: android canvas line thickness 
Java :: java memory increase command 
Java :: java program using FileOutputStream to create a file on mac 
Java :: palindrome java 
Java :: how to multiply bigdecimals 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =