tane_superior

Untitled

Apr 30th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. public delegate void nextLoop(int[,] nigger, int lastNum, int finalNum, int corridorCount, bool direction, int lastLoop1, int lastLoop2);
  8.  
  9. class Program
  10. {
  11.     static void Main(string[] args)
  12.     {
  13.         int n = 0;
  14.         try
  15.         {
  16.             if (!int.TryParse(Console.ReadLine(), out n) || n > 10 || n < 1)
  17.                 throw new ArgumentException("are you fucking retarded");
  18.         }
  19.         catch (Exception ex)
  20.         {
  21.             Console.WriteLine(ex.Message);
  22.         }
  23.  
  24.         int[,] ninja = new int[n, n];
  25.         Methods.NumSnailLoop(ninja, 0, n * n, 1, true, 0, 0);
  26.  
  27.         for (int i = 0; i < ninja.GetLength(0); i++)
  28.         {
  29.             for (int j = 0; j < ninja.GetLength(0); j++)
  30.                 Console.Write(ninja[i, j] + " ");
  31.             Console.WriteLine();
  32.         }
  33.     }
  34. }
  35.  
  36. static class Methods
  37. {
  38.     static public event nextLoop Reactionary = NumSnailLoop;
  39.  
  40.     public static void NumSnailLoop(int[,] nigger, int lastNum, int finalNum, int corridorCount, bool direction, int lastLoop1, int lastLoop2)
  41.     {
  42.         if (corridorCount % 2 == 1)
  43.         {
  44.             if (direction)
  45.             {
  46.                 for (; lastLoop2 < nigger.GetLength(0) && nigger[lastLoop1, lastLoop2] == 0; lastLoop2++)
  47.                 {
  48.                     lastNum += 1;
  49.                     nigger[lastLoop1, lastLoop2] = lastNum;
  50.                 }
  51.                 lastLoop2--; // lastLoop2 = lastLoop2 - 1;
  52.                 lastLoop1++;
  53.             }
  54.             else
  55.             {
  56.                 for (; lastLoop2 >= 0 && nigger[lastLoop1, lastLoop2] == 0; lastLoop2--)
  57.                 {
  58.                     lastNum += 1;
  59.                     nigger[lastLoop1, lastLoop2] = lastNum;
  60.                 }
  61.                 lastLoop2++;
  62.                 lastLoop1--;
  63.             }
  64.         }
  65.         else
  66.         {
  67.             if (direction)
  68.             {
  69.                 for (; (lastLoop1 < nigger.GetLength(0) && nigger[lastLoop1, lastLoop2] == 0); lastLoop1++)
  70.                 {
  71.                         lastNum += 1;
  72.                         nigger[lastLoop1, lastLoop2] = lastNum;
  73.                 }
  74.                 lastLoop1--;
  75.                 lastLoop2--;
  76.             }
  77.             else
  78.             {
  79.                 for (; (lastLoop1 >= 0 && nigger[lastLoop1, lastLoop2] == 0); lastLoop1--)
  80.                 {
  81.                         lastNum += 1;
  82.                         nigger[lastLoop1, lastLoop2] = lastNum;
  83.                 }
  84.                 lastLoop1++;
  85.                 lastLoop2++;
  86.             }
  87.             direction = !direction;
  88.         }
  89.         corridorCount++;
  90.         if(lastNum < finalNum)
  91.             NumSnailLoop(nigger, lastNum, finalNum, corridorCount, direction: direction, lastLoop1: lastLoop1, lastLoop2);
  92.     }
  93. }
Add Comment
Please, Sign In to add comment