1.
*****
*****
*****
*****
*****
public class Star01 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
2. 대각선
*
*
*
*
*
public class Star02 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if (i == j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
3. 대각선2
*
*
*
*
*
public class Star03 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if (i == 6 - j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
4. X자
* *
* *
*
* *
* *
public class Star04 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if (i == j || i == 6 - j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
5.
*
**
***
****
*****
public class Star05 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if (i >= j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
6.
*
**
***
****
*****
public class Star06 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if (i >= 6 - j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
7.
******
*******
********
*********
**********
public class Star07 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i + 5; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
8.
*
***
*****
*******
**********
public class Star08 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i + 4; j++) {
if (i >= 6 - j) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
9.
*****
***
*
***
*****
public class Star09 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if ((i <= 6 - j && i <= j) || (i >= j && i >= 6 - j)) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
10.
* *
** **
*****
** **
* *
public class Star10 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 5; j++) {
if (!((i < 6 - j && i < j) || (i > j && i > 6 - j))) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}