- class PrintTriggle
- {
- public static void printTriggle(int count)
- {
- for(int x=0;x<count;x++)
- {
- niubi(count,x);
- }
-
- for(int x=count-2;x>=0;x--)
- {
- niubi(count,x);
- }
- }
-
- private static void niubi(int count,int x)
- {
- for(int j=0;j<count-1-x;j++)
- {
- System.out.print(" ");
- }
- System.out.print("*");
- for(int z=0;z<x;z++)
- {
- System.out.print(" *");
- }
- System.out.println();
- }
- }
- public class Child {
- public static void main(String[] args) {
-
- PrintTriggle.printTriggle(14);
-
- }
-
- }
- class PrintTriggle
- {
- public static void printTriggle(int count)
- {
- for(int x=0;x<count;x++)
- {
- niubi(count,x);
- }
-
- for(int x=count-2;x>=0;x--)
- {
- niubi(count,x);
- }
- }
-
- private static void niubi(int count,int x)
- {
- for(int j=0;j<count-1-x;j++)
- {
- System.out.print(" ");
- }
- System.out.print("*");
- for(int z=0;z<x;z++)
- {
- System.out.print(" *");
- }
- System.out.println();
- }
- }
- public class Child {
- public static void main(String[] args) {
-
- PrintTriggle.printTriggle(14);
-
- }
-
- }
复制代码
//把菱形分成两个,一个上三角形,一个下三角形;
//上三角形输出空格和星
//下三角形输出空格和星 |