图形打印
1.编程输出如下图案:
public class PrintPic01{
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int j = 1; j <= 7; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
2.编程输出如下图案:
public class PrintPic02 {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int k = 1; k <= 7 - i; k++) {
System.out.print(" ");
}
for (int j = 1; j <= 7; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
3.编程输出如下图案:
public class PrintPic03 {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
4.编程输出如下图案:
public class PrintPic04 {
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();
}
}
}
5.编程输出如下图案:
public class PrintPic05 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= 6-i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
6.编程输出如下图案:
public class PrintPic06 {
public static void main(String[] args) {
for (int i = 1; i <= 5; i++) {
for(int j = 1;j<=i-1;j++) {
System.out.print(" ");
}
for (int j = 1; j <= 6-i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
7.编程输出如下图案:
public class PrintPic07 {
public static void main(String[] args) {
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 4-i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
8.编程输出如下图案:
public class PrintPic08 {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int k = 1; k <= 7 - i; k++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
9.编程输出如下图案:
public class PrintPic09 {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int k = 1; k <= 7 - i; k++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= 5; i++) {
System.out.println(" *");
}
}
}
10.编程输出如下图案:
public class PrintPic10 {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int j = 1; j <= 7 - i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
System.out.print("*");
}
System.out.println();
}
for (int i = 1; i <= 6; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= 13 - 2 * i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
11.编程输出如下图案:
public class PrintPic11 {
public static void main(String[] args) {
for (int i = 1; i <= 7; i++) {
for (int j = 1; j <= 7 - i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
if (j == 1 || j == 2 * i - 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
for (int i = 1; i <= 6; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(" ");
}
for (int j = 1; j <= 13 - 2 * i; j++) {
if (j == 1 || j == 13 - 2 * i) {
System.out.print("*");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}
12.编程输出如下图案:
public class PrintPic12 {
public static void main(String[] args) {
for (int i = 1; i <= 6; i++) {
for (int k = 1; k <= 6 - i; k++) {
System.out.print(" ");
}
for (int j = 1; j <= 2 * i - 1; j++) {
if (j <= i) {
System.out.print(j);
} else {
System.out.print(2 * i - j);
}
}
System.out.println();
}
}
}
13.编程输出如下图案:
public class PrintPic13 {
public static void main(String[] args) {
fz1();
}
public static int abs(int i) {
if (i >= 0) {
return i;
} else {
return -i;
}
}
public static void fz1() {
for (int i = -5; i <= 5; i++) {
for (int j = -5; j <= 5; j++) {
System.out.print((5 - abs(i)) + " ");
}
System.out.println();
}
}
}
14.编程输出如下图案:
public class PrintPic14 {
public static void main(String[] args) {
fz2();
}
public static int abs(int i) {
if (i >= 0) {
return i;
} else {
return -i;
}
}
public static void fz2() {
for (int i = -5; i <= 5; i++) {
for (int j = -5; j <= 5; j++) {
System.out.print((5 - abs(j)) + " ");
}
System.out.println();
}
}
}
15.编程输出如下图案:
public class PrintPic15 {
public static void main(String[] args) {
fz3();
}
public static int abs(int i) {
if (i >= 0) {
return i;
} else {
return -i;
}
}
public static void fz3() {
for (int i = -5; i <= 5; i++) {
for (int j = -5; j <= 5; j++) {
if (abs(i) > abs(j)) {
System.out.print((5 - abs(i)) + " ");
} else {
System.out.print((5 - abs(j)) + " ");
}
}
System.out.println();
}
}
}