PTA 7-6 again on a digital triangular cam (10 points) to be improved]

Triangular enter a positive integer n, the n-layer having a digital output triangle.

Input formats:

Only a positive integer n, 1 <= n <= 100.

Output formats:

An upper triangular numbers triangle, each figure represents four character positions.

Sample input:

5
 

Sample output:

   1   6  10  13  15
   2   7  11  14
   3   8  12
   4   9
   5

Author: Weng Kai
Unit: Zhejiang University
Time limit: 400 ms
Memory Limit: 64 MB
Code length limit: 16 KB
 
 1 import java.io.BufferedReader;
 2 import java.io.IOException;
 3 import java.io.InputStreamReader;
 4 public class Main {
 5     public static void main(String[] args) throws IOException{
 6         BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
 7         String t=input.readLine();
 8         int n=Integer.parseInt(t);
 9         for(int i=1;i<=n;i++){
10             int k=i;
11             for(int j=1;j<=n-i+1;j++){
12                 System.out.printf("%4d",k);
13                 k+=n-j+1;
14             }
15             System.out.println();
16         }
17         
18     }
19 }

Hard to scrape scrape out. . . Available look at law

Guess you like

Origin www.cnblogs.com/Flyfishy/p/12173870.html