Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace RotateArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[][] test = new int[][]{new int[]{4,5,6,7},
- new int[]{1,3,5,7},
- new int[]{9,5,4,2}};
- PrintArray(test);
- int[][] result = ExpandArray(test);
- PrintArray(result);
- Console.ReadLine();
- }
- public static int[][] ExpandArray(int[][] input)
- {
- int[][] result = new int[input.Length * 2][];
- for (int y1 = 0, y2 = 0; y1 < input.Length; y1++, y2 += 2)
- {
- result[y2] = new int[input[y1].Length * 2];
- for (int x1 = 0, x2 = 0; x1 < input[y1].Length; x1++, x2 += 2)
- result[y2][x2 + 1] = (result[y2][x2] = input[y1][x1]);
- result[y2 + 1] = (int[])result[y2].Clone();
- }
- return result;
- }
- private static void PrintArray(int[][] input)
- {
- for (int y = 0; y < input.Length; y++)
- {
- for (int x = 0; x < input[y].Length; x++)
- Console.Write(input[y][x] + ",");
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment