SHOW:
|
|
- or go back to the newest paste.
| 1 | - | using System; |
| 1 | + | using System; |
| 2 | - | using System.Collections.Generic; |
| 2 | + | using System.Collections.Generic; |
| 3 | - | using System.Linq; |
| 3 | + | using System.Linq; |
| 4 | - | using System.Text; |
| 4 | + | using System.Text; |
| 5 | - | using System.Threading.Tasks; |
| 5 | + | using System.Threading.Tasks; |
| 6 | - | |
| 6 | + | |
| 7 | - | namespace ConsoleApp1 |
| 7 | + | namespace ConsoleApp1 |
| 8 | - | { |
| 8 | + | {
|
| 9 | - | class Program |
| 9 | + | class Program |
| 10 | - | { |
| 10 | + | {
|
| 11 | - | static void Main(string[] args) |
| 11 | + | static void Main(string[] args) |
| 12 | - | { |
| 12 | + | {
|
| 13 | - | const int n = 7; |
| 13 | + | const int n = 7; |
| 14 | - | int[] A = new int[n*n] { |
| 14 | + | int[] A = new int[n*n] {
|
| 15 | - | 1, 3, 3, 7, 4, 8, 8, |
| 15 | + | 1, 3, 3, 7, 4, 8, 8, |
| 16 | - | 1, 3, 3, 7, 4, 8, 8, |
| 16 | + | 1, 3, 3, 7, 4, 8, 8, |
| 17 | - | 1, 3, 3, 7, 4, 8, 8, |
| 17 | + | 1, 3, 3, 7, 4, 8, 8, |
| 18 | - | 1, 3, 3, 7, 4, 8, 8, |
| 18 | + | 1, 3, 3, 7, 4, 8, 8, |
| 19 | - | 1, 3, 3, 7, 4, 8, 8, |
| 19 | + | 1, 3, 3, 7, 4, 8, 8, |
| 20 | - | 1, 3, 3, 7, 4, 8, 8, |
| 20 | + | 1, 3, 3, 7, 4, 8, 8, |
| 21 | - | 1, 3, 3, 7, 4, 8, 8 |
| 21 | + | 1, 3, 3, 7, 4, 8, 8 |
| 22 | - | }; |
| 22 | + | }; |
| 23 | - | |
| 23 | + | |
| 24 | - | int[] vec = new int[2 * n - 1]; |
| 24 | + | int[] vec = new int[2 * n - 1]; |
| 25 | - | for(int j = 0; j < n; j++) |
| 25 | + | for(int j = 0; j < n; j++) |
| 26 | - | { |
| 26 | + | {
|
| 27 | - | vec[(2*n - 1)/2] += A[n*j + j]; |
| 27 | + | vec[(2*n - 1)/2] += A[n*j + j]; |
| 28 | - | for(int f = 1; f < n; f++) |
| 28 | + | for(int f = 1; f < n; f++) |
| 29 | - | { |
| 29 | + | {
|
| 30 | - | if(j-f >= 0) |
| 30 | + | if(j-f >= 0) |
| 31 | - | vec[(2*n - 1)/2 - f] += A[n*(j - f) + j]; |
| 31 | + | vec[(2*n - 1)/2 - f] += A[n*(j - f) + j]; |
| 32 | - | |
| 32 | + | |
| 33 | - | if(j + f < n) |
| 33 | + | if(j + f < n) |
| 34 | - | vec[(2 * n - 1)/2 + f] += A[n*(j + f) + j]; |
| 34 | + | vec[(2 * n - 1)/2 + f] += A[n*(j + f) + j]; |
| 35 | - | } |
| 35 | + | } |
| 36 | - | } |
| 36 | + | } |
| 37 | - | |
| 37 | + | |
| 38 | - | for(int i = 0; i < 2*n - 1; i++) |
| 38 | + | for(int i = 0; i < 2*n - 1; i++) |
| 39 | - | Console.Write("{0:d} ", vec[i]); |
| 39 | + | Console.Write("{0:d} ", vec[i]);
|
| 40 | - | Console.ReadKey(); |
| 40 | + | Console.ReadKey(); |
| 41 | - | } |
| 41 | + | } |
| 42 | - | } |
| 42 | + | } |
| 43 | } |