Advertisement
libdo

Untitled

Nov 4th, 2017
6,857
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. const int n = 7;
  14. int[] A = new int[n*n] {
  15. 1, 3, 3, 7, 4, 8, 8,
  16. 1, 3, 3, 7, 4, 8, 8,
  17. 1, 3, 3, 7, 4, 8, 8,
  18. 1, 3, 3, 7, 4, 8, 8,
  19. 1, 3, 3, 7, 4, 8, 8,
  20. 1, 3, 3, 7, 4, 8, 8,
  21. 1, 3, 3, 7, 4, 8, 8
  22. };
  23.  
  24. int[] vec = new int[2 * n - 1];
  25. for(int j = 0; j < n; j++)
  26. {
  27. vec[(2*n - 1)/2] += A[n*j + j];
  28. for(int f = 1; f < n; f++)
  29. {
  30. if(j-f >= 0)
  31. vec[(2*n - 1)/2 - f] += A[n*(j - f) + j];
  32.  
  33. if(j + f < n)
  34. vec[(2 * n - 1)/2 + f] += A[n*(j + f) + j];
  35. }
  36. }
  37.  
  38. for(int i = 0; i < 2*n - 1; i++)
  39. Console.Write("{0:d} ", vec[i]);
  40. Console.ReadKey();
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement