Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void WriteArray(int[,] x)
- {
- for (int i = 0; i < x.GetLength(0); i++)
- {
- for (int j = 0; j < x.GetLength(1); j++)
- Write("{0} ", x[i, j]);
- WriteLine();
- }
- WriteLine();
- }
- delegate void mat(int[,] x, int y);
- static void up(int[,] x, int y)
- {
- for (int i = 0; i < x.GetLength(1); i++)
- {
- int xmin = x[y, i];
- for (int j = i; j < x.GetLength(1); j++)
- {
- if (x[y, j] < xmin)
- {
- xmin = x[y, j];
- for (int k = j; k > i; k--)
- {
- x[y, k] = x[y, k - 1];
- }
- x[y, i] = xmin;
- }
- }
- }
- }
- static void down(int[,] x, int y)
- {
- for (int i = 0; i < x.GetLength(1); i++)
- {
- int xmax = x[y, i];
- for (int j = i; j < x.GetLength(1); j++)
- {
- if (x[y, j] > xmax)
- {
- xmax = x[y, j];
- for (int k = j; k > i; k--)
- {
- x[y, k] = x[y, k - 1];
- }
- x[y, i] = xmax;
- }
- }
- }
- }
- static void Matrix(mat even, int[,] a, int x)
- {
- for (int i = x; i < a.GetLength(0); i += 2)
- {
- even(a, i);
- }
- }
- static void Main(string[] args)
- {
- int[,] a = new int[,]
- {
- { 4, 5, 1, 7 } ,
- { 9, 4, 3, 7 }
- };
- WriteArray(a);
- Matrix(up, a, 0);
- Matrix(down, a, 1);
- WriteArray(a);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement