fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace Test
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Random r = new Random();
  14. int size = 10;// int.Parse(Console.ReadLine());
  15. int[,] arrA = new int[size, size];
  16. int[,] arrB = new int[size, size];
  17. for (int w = 0; w < size; w++)
  18. for (int h = 0; h < size; h++)
  19. arrA[w, h] = r.Next(10);
  20.  
  21. int a1 = 0;
  22. int b1 = 0;
  23. int a2 = 0;
  24. int b2 = 0;
  25. for (int w = 0; w < size; w++)
  26. for (int h = 0; h < size; h++)
  27. {
  28. int counter = 0;
  29. int i = w;
  30. int j = h;
  31. for (a1 = i + 1, b1 = j - 1; b1 < size && a1 >= 1; a1--, b1++)
  32. for (int k = b1; k + 1 < size; counter += arrA[a1 - 1, k + 1], k++) ;
  33. for (a2 = i + 1, b2 = j + 1; b2 < size && a2 < size; a2++, b2++)
  34. for (int k = b2; k < size; counter += arrA[a2, k], k++) ;
  35.  
  36. arrB[i, j] = counter;
  37. }
  38.  
  39. Console.WriteLine("Array A:");
  40. for (int w = 0; w < size; w++)
  41. {
  42. for (int h = 0; h < size; h++)
  43. Console.Write(arrA[w, h].ToString() + " ");
  44. Console.WriteLine();
  45. }
  46. Console.WriteLine();
  47. Console.WriteLine("Array B:");
  48. for (int w = 0; w < size; w++)
  49. {
  50. for (int h = 0; h < size; h++)
  51. Console.Write(arrB[w, h].ToString() + " ");
  52. Console.WriteLine();
  53. }
  54. }
  55. }
  56. }
Success #stdin #stdout 0s 29664KB
stdin
Standard input is empty
stdout
Array A:
6 8 8 2 1 2 1 0 8 5 
8 7 1 4 5 9 9 5 6 2 
7 8 9 2 1 5 8 6 1 3 
4 5 4 8 3 4 5 0 3 3 
9 4 8 9 3 5 8 5 8 8 
8 8 8 1 4 7 8 5 1 5 
3 4 9 5 1 2 3 3 0 0 
3 8 1 2 3 3 0 0 8 6 
7 3 8 3 4 5 7 2 3 5 
5 9 9 7 0 5 4 3 8 1 

Array B:
242 195 152 116 93 62 34 24 15 5 
281 228 179 142 113 90 59 33 16 2 
300 250 210 171 130 96 71 37 9 3 
311 267 225 187 151 105 61 33 17 3 
333 277 235 193 151 109 58 36 24 8 
321 288 233 182 139 96 71 36 14 5 
322 261 219 170 122 90 59 36 11 0 
299 246 185 145 115 82 50 28 19 6 
274 212 163 127 100 69 48 33 15 5 
226 181 143 107 74 57 40 26 14 1