Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int row = 0; row < matrix.Length; row++)
- {
- var arr = matrix[row];
- arr = arr.Where(s => s != 0).ToArray();
- int areAllZeros = 0;
- // check if the whole row is zeros
- bool allEqual = arr
- .All(currentRowToCheck => int.Equals(areAllZeros, currentRowToCheck));
- // if the row contains elements different from zeros
- if (!allEqual)
- {
- initializeMatrixToPrint.Enqueue(arr);
- }
- }
- matrix = new int[initializeMatrixToPrint.Count][];
- for (int i = 0; i < matrix.Length; i++)
- {
- matrix[i] = initializeMatrixToPrint.Dequeue();
- }
Add Comment
Please, Sign In to add comment