首页 > 代码库 > URAL 1313 Some Words about Sport

URAL 1313 Some Words about Sport

斜着数

 1 import java.util.Scanner; 2  3 public class P1313 4 { 5     public static void main(String args[]) 6     { 7         try (Scanner cin = new Scanner(System.in)) 8         { 9             while (cin.hasNext())10             {11                 int n = cin.nextInt();12                 int a[][] = new int[n][n];13                 for (int i = 0; i < n; i++)14                     for (int j = 0; j < n; j++)15                         a[i][j] = cin.nextInt();16                 for (int k = 0; k < 2 * n - 1; k++)17                     for (int j = 0; j < n; j++)18                     {19                         int i = k - j;20                         if (i >= 0 && i < n)21                             System.out.print(a[i][j] + " ");22                     }23                 System.out.println();24             }25         }26     }27 }

 

URAL 1313 Some Words about Sport