cloudsin
BAN USER
RepPal A Roos is the best early childhood & child development center in Charlotte. We are famous offering full-time, part-time and ...
RepDiscover the best online vaporizer store to buy quality vaping accessories at affordable price. Visit NY Vape Shop, specialized in ...
Repour goal is to help individuals companies and organizations of all kinds to communicate with their clients customer and employees ...
RepAre you searching for the most powerful and very strong mantra for your husband? If you want to do Jadoo ...
RepRocioNavarro189, None at Student
Hello Everyone,My name is Rocio Navarro Form Auckland,NZ,and 31 years old.I am searching for a servant ...
RepLarry Alvarez, Analyst at ASU
Prestige Luxury Rentals is one of the most renowned car rental companies in USA. We are locally owned and operated ...
RepChristinaDDooley, Tech Lead at Car Rental
Rent the stylish, royal & Luxury Cars in Miami.We have become known worldwide by providing Luxury car rental Miami and ...
RepIf you want to attract someone then astrologer kumar can help you. Astrologer kumar is specialized in offering kamdev vashikaran ...
I did some tweaking to handle all zeros in the matrix. Here is the code (tested)
- cloudsin January 16, 2014int[,] array =
{
{0, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 0, 11},
{12, 13, 14, 15}
};
int[,] finalarray = new int[array.GetLength(0), array.GetLength(1)];
Array.Copy(array, 0,finalarray, 0,array.Length);
int row = 0;
int col = 0;
for (int i = 0; i < array.GetLength(0); i++)
{
for (int j = 0; j < array.GetLength(1); j++)
{
if (array[i, j] == 0)
{
for (int zerorow = 0; zerorow < array.GetLength(0); zerorow++)
{
for (int zerocol = 0; zerocol < array.GetLength(1); zerocol++)
{
if(zerorow == i)
finalarray[zerorow, zerocol] = 0;
if(j==zerocol)
finalarray[zerorow, zerocol] = 0;
}
}
row = i;
col = j;
}
}
}