- package com.sf;
- import java.util.*;
- public class test5 {
- public static void main(String[] args) {
-
- System.out.println("请输入第一个三角形的腰");
-
- Scanner sc = new Scanner(System.in);
- int length1 = sc.nextInt();
-
- System.out.println("请输入第二个三角形的腰");
- int length2 = sc.nextInt();
-
- System.out.println("请输入矩形的长");
- int length3 = sc.nextInt();
- triangle(length1);
- triangle(length2);
- rectangle(length3);
- sc.close();
- }
- private static void triangle(int length){
- for(int x=0; x<length; x++){
- printKong(x);
- for(int z=0;z<x+1;z++){
- System.out.print("*");
- }
- for(int z=0;z<x;z++){
- System.out.print("*");
- }
- System.out.println();
- }
- }
- private static void rectangle(int length){
- for(int x=0; x<length; x++){
- printKong(1);
- for(int y=0; y<3;y++){
- System.out.print("*");
- }
- System.out.println();
- }
-
- }
- private static void printKong(int x){
- for(int y=0; y<16-x;y++){
-
- System.out.print(" ");
- }
-
- }
- }
复制代码
f:\\1.png |
|