import java.util.Scanner;
public class Pro06 {
public static void main(String[] args) {
System.out.print("Enter N:");
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for(int i = N; i<0;i--) {
for(int j =1; j<i+1;j++) {
System.out.print("★");
}
System.out.println("");
}
}
}
If I put 5 in the N value, I want to print out the following stars.
★★★★★
★★★★
★★★
★★
★
java for print-asterisk
int N = 5;
for(int i = N; i > 0 ; i--) {
for(int j = 0; j < i; j++) {
System.out.print("★");
}
System.out.println("");
}
The code itself is a way of weaving like above, but....
This type of question has the same homework solution, so I don't like to answer it on the Internet.
https://ko.wikibooks.org/wiki/%EB%B3%84_%EC%B0%8D%EA%B8%B0
If you look at these links, there are many ways to solve them, so if you don't understand, I recommend you to search and analyze them steadily by looking at various codes.
© 2024 OneMinuteCode. All rights reserved.