Created
November 6, 2020 13:03
-
-
Save hypnguyen1209/f5a3de547a936216b3a9059611a59350 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class bai4 { | |
| public static void main(String args[]) { | |
| Scanner in = new Scanner(System.in); | |
| int num = in.nextInt(); | |
| triangle(num); | |
| } | |
| private static void triangle(int num) { | |
| for(int i = 1; i <= num; i++) { | |
| for(int j = 1; j <= num-i; j++) { | |
| System.out.printf(" "); | |
| } | |
| for(int j = 1; j <= i; j++) { | |
| System.out.printf("* "); | |
| } | |
| System.out.printf("\n"); | |
| } | |
| return; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment