打印三角形(题)

 1 import java.util.*;
 2 public class hello 
 3 {
 4     public static void main(String[] args)
 5     {
 6         Scanner s=new Scanner(System.in);
 7         System.out.println("请输入");
 8         int n=s.nextInt();
 9         for(int a=1;a<=n;a++)
10         {
11             for(int b=1;b<=n-a;b++)
12             {
13                 System.out.print(" ");
14             }
15             for(int c=1;c<=a;c++)
16             {
17                 System.out.print("*");
18             }
19             System.out.println();
20         }
21         
22         
23         
24         
25         
26         
27         for(int a=1;a<=n;a++)
28         {
29             for(int b=1;b<=a;b++)
30             {
31                 System.out.print("*");
32             }      
33             System.out.println();
34         }
35         
36         
37         
38         
39         
40         System.out.println();
41         
42         
43            
44         
45         
46         for(int a=n;a>=1;a--)
47         {
48             for(int b=1;b<=a;b++)
49             {
50                 System.out.print("*");
51             }
52             System.out.println();
53         }
54        
55         
56         
57         
58         
59         for(int a=1;a<=n;a++)
60         {
61             for(int b=1;b<a;b++)
62             {
63                 System.out.print(" ");
64             }
65             for(int c=n-a+1;c>=1;c--)
66             {
67                 System.out.print("*");
68             }
69             
70             System.out.println();
71         }
72     }
73 }

 

posted @ 2016-05-10 22:07  明天会更好!!!!  阅读(141)  评论(0)    收藏  举报