_CodeBehind

asdasdas

Jun 4th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1.  
  2.  
  3.                 for (int row = 0; row < matrix.Length; row++)
  4.                 {
  5.                     var arr = matrix[row];
  6.                     arr = arr.Where(s => s != 0).ToArray();
  7.  
  8.                     int areAllZeros = 0;
  9.  
  10.                     // check if the whole row is zeros
  11.                     bool allEqual = arr
  12.                       .All(currentRowToCheck => int.Equals(areAllZeros, currentRowToCheck));
  13.                     // if the row contains elements different from zeros  
  14.                     if (!allEqual)
  15.                     {
  16.                         initializeMatrixToPrint.Enqueue(arr);
  17.                     }
  18.                 }
  19.                 matrix = new int[initializeMatrixToPrint.Count][];
  20.                 for (int i = 0; i < matrix.Length; i++)
  21.                 {
  22.                     matrix[i] = initializeMatrixToPrint.Dequeue();
  23.                 }
Add Comment
Please, Sign In to add comment