Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace _42.Parcurgere_în_spirală
- {
- class Program
- {
- static void Main(string[] args)
- {
- int p;
- p = int.Parse(Console.ReadLine());
- int[,] n= new int[p,p];
- for(int i = 0; i <= n.Length; i++)
- {
- for(int j = 0; j < n.Length; j++)
- {
- n[i,j] = int.Parse(Console.ReadLine());
- }
- }
- int q = n.Length;
- int c = 0;
- while (q != 0)
- {
- c++;
- if((c==n.Length/2+1) && (q == n.Length / 2 + 1))
- {
- Console.WriteLine(n[c,q]);
- continue;
- }
- for(int i = c; i < q; i++)
- {
- Console.WriteLine(i);
- }
- for(int i = c+1; i < q; i++)
- {
- Console.WriteLine(n[i,q-1]);
- }
- for(int i = q - 2; i >= c; i--)
- {
- Console.WriteLine(n[q-1,i]);
- }
- for(int i = q - 2; i >= c+1; i--)
- {
- Console.WriteLine(n[0,i]);
- }
- q--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement