Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. Console.Write("n= ");
  2.             int n = int.Parse(Console.ReadLine());
  3.             int[,] a = new int[n,n];
  4.             for (int redove = 0; redove < n; redove++)
  5.             {
  6.                 for (int koloni = 0; koloni < n; koloni++)
  7.                 {
  8.                     a[redove, koloni] = int.Parse(Console.ReadLine());
  9.                 }
  10.             }
  11.  
  12.             int[] c = new int[n * n];
  13.             int k = 0;
  14.             for (int redove = 0; redove < n; redove++)
  15.             {
  16.                 if(redove%2==0)
  17.                 {
  18.                
  19.                     for (int koloni = n-1; koloni >= 0; koloni--)
  20.                     {
  21.                         c[k] = a[redove, koloni];
  22.                         k++;
  23.                     }
  24.             }
  25.                 else
  26.                 {
  27.                     for (int koloni = n-1; koloni >= 0; koloni--)
  28.                     {
  29.                         c[k] = a[redove, koloni];
  30.                         k++;
  31.                     }
  32.                 }
  33.             }
  34.                
  35.                Console.WriteLine("Елементите на c са: ");
  36.             for (int i = 0; i < k; i++)
  37.             {
  38.                 Console.Write(c[i] + " ");
  39.             }
  40.       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement