Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Изменить_размер_массива
- {
- class Program
- {
- static void ShowArray(int[,] arrNums)
- {
- for (int intC = 0; intC < arrNums.GetLength(0); intC++)
- {
- for (int intB = 0; intB <arrNums.GetLength(1); intB++)
- Console.Write(arrNums[intC, intB] + " ");
- Console.WriteLine();
- }
- }
- static int[,] ResizeArray(int[,] arrNums, int[] arrSizes)
- {
- int[,] arrTemp = new int[arrSizes[0], arrSizes[1]];
- for (int intC = 0; intC < (Math.Min(arrNums.GetLength(0), arrSizes[0])); intC++)
- for (int intB = 0; intB < (Math.Min(arrNums.GetLength(1), arrSizes[1])); intB++)
- arrTemp[intC, intB] = arrNums[intC, intB];
- return arrTemp;
- }
- static void Main(string[] args)
- {
- int[,] arrZ = { { 1, 2, 3, 4, 5, 6 }, { 7, 8, 9, 10, 11, 12 } };
- arrZ = ResizeArray(arrZ, new int[] { 4, 3});
- ShowArray(arrZ);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement