PowerSlaveAlfons

Untitled

May 30th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class Kata
  6. {
  7.   public static int[] ArrayDiff(int[] a, int[] b)
  8.   {
  9.    // Console.WriteLine(a[0]);
  10.    
  11.     int[] c = new int[] {};
  12.     int temp = 0;
  13.     int temp2 = 0;
  14.     c=a;
  15.  
  16.     for (int i=0; i<c.Length; i++)
  17.     {
  18.       temp = c[i];
  19.      
  20.       for (int j=0; j<b.Length; j++)
  21.       {      
  22.         temp2 = b[j];
  23.         if (temp == temp2)
  24.         {          
  25.         c = RemoveAt(c, i);
  26.         if (i >= 1)
  27.         {  i = 0;
  28.         j --;
  29.           break;}
  30.        // else if (i == 1)
  31.      //   else  i = 0;
  32.        //   break;}
  33.         }  
  34.        
  35.        
  36.       }      
  37.     }  
  38.    
  39.    for (int k = 0; k < c.Length; k++)  // debug Stuff
  40.         {  
  41.            Console.WriteLine(c[k]);
  42.         }
  43.     Console.WriteLine("");
  44.    // Console.WriteLine(b[0]);
  45.    return c;
  46.  }
  47.  
  48.   public static int[] RemoveAt(int[] arr, int index)
  49. {
  50.    for (int f = index; f < arr.Length - 1; f++)
  51.     {
  52.         arr[f] = arr[f + 1];
  53.     }
  54.     if (arr.Length > 0)
  55.     Array.Resize(ref arr, arr.Length - 1);
  56.    
  57.     return arr;
  58. }
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment