Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace array
- {
- class Array
- {
- public bool errFlag;
- int [,] arr;
- int length;
- public Array(int length)
- {
- this.length = length;
- arr = new int[length, length];
- Console.WriteLine();
- }
- public static Array operator %(Array ob1, int ob2)
- {
- for (int i = 0; i < length; i++)
- {
- for (int j = 0; j < length; j++)
- {
- ob1[i, j] = ob1[i, j] % ob2;
- }
- }
- return ob1;
- }
- public void SetArr()
- {
- Console.WriteLine("Заполните массив данными");
- for (int i = 0; i < length; i++)
- {
- for (int j = 0; j < length; j++)
- {
- Console.Write("Введите значение элемента массива {0}-{1}: ", i + 1, j + 1);
- arr[i, j] = int.Parse(Console.ReadLine());
- }
- }
- }
- public void GetArr()
- {
- Console.WriteLine("Значения элементов массива:");
- for (int i = 0; i < length; i++)
- {
- for (int j = 0; j < length; j++)
- {
- Console.Write(arr[i, j] + "\t");
- }
- Console.WriteLine();
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Введите размер массивов с которыми предстоит работать: ");
- int length = int.Parse(Console.ReadLine());
- Array firstArr = new Array(length);
- firstArr.SetArr();
- firstArr.GetArr();
- Console.Write("Введите число, с помощью которого будут найдены остатки от деления всех элементов массива : ");
- int x = int.Parse(Console.ReadLine());
- firstArr = firstArr % x;
- Console.WriteLine("Новый массив, который состоит из остатков от деления");
- firstArr.GetArr();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment