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;
- namespace Task1010
- {
- class Program
- {
- static void Main(string[] args)
- {
- }
- static void PrintArray(int[,] arr)
- {
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- Console.Write(arr[i,j] + ",");
- }
- Console.WriteLine();
- }
- }
- static int[,] CreateArray()
- {
- int[,] arr = new int[15, 20];
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- arr[i, j] = i;
- }
- }
- return arr;
- }
- static int[,] Kefel()
- {
- int[,] arr = new int[10, 10];
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- arr[i, j] = (i + 1) * (j + 1);
- }
- }
- return arr;
- }
- static int[,] CreateRandom(int r, int c)
- {
- Random rand = new Random();
- int[,] arr = new int[r, c];
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- arr[i, j] = rand.Next(0,10);
- }
- }
- return arr;
- }
- static void FindMax(int[,] arr)
- {
- int max = 0;
- string maxim = "";
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- if (arr[i, j] > max)
- {
- max = arr[i, j];
- }
- }
- }
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- if (arr[i, j] == max)
- {
- maxim += i.ToString() + "," + j.ToString() + " ";
- }
- }
- }
- Console.WriteLine("The max number was: " + max);
- Console.WriteLine("It appeared in: " + maxim);
- }
- static void Diagnol(int[,] arr)
- {
- if (arr.GetLength(0) != 6 || arr.GetLength(1) != 6)
- {
- Console.WriteLine("There was a problem with the array that was put in");
- return;
- }
- PrintArray(arr);
- Console.WriteLine();
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- for (int j = 0; j < arr.GetLength(1); j++)
- {
- if (i == j)
- arr[i, j] = 1;
- if (j < i)
- arr[i, j] = 0;
- }
- }
- }
- static void Inner(int[,] arr)
- {
- int[,] arr2 = new int[5, 5];
- if(arr.GetLength(0) != 7 || arr.GetLength(1) != 7)
- {
- Console.WriteLine("There was a problem with the array");
- return;
- }
- PrintArray(arr);
- Console.WriteLine();
- for (int i = 0; i < arr2.GetLength(0); i++)
- {
- for (int j = 0; j < arr2.GetLength(1); j++)
- {
- arr2[i, j] = arr[i, j];
- }
- }
- PrintArray(arr2);
- }
- static bool IsPositive()
- {
- int summain = 0;
- int sumsec = 0;
- int[,] arr = CreateRandom(7, 7);
- PrintArray(arr);
- Console.WriteLine();
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- summain += arr[i, i];
- }
- for (int i = 0; i < arr.GetLength(0); i++)
- {
- sumsec += arr[i, arr.GetLength(0) - 1 - i];
- }
- if (summain > sumsec)
- return true;
- return false;
- }
- static bool IsMagic(int n,int[,] arr)
- {
- int sumAlahson1=0;
- int sumAlahson2=0;
- for(int i=0;i<n;i++){
- sumAlahson1+=arr[i,i];
- sumAlahson2+=arr[arr.Length-i,arr.Length-i];
- }
- if(sumAlahson1!=sumAlahson2)
- return false;
- for(int i=0;i<n;i++){
- int sumRow=0,sumColumn=0;
- for(int j=0;j<n;j++){
- sumRow+=arr[i,j];
- sumColumn+=arr[j,i];
- }
- if(sumRow!=sumAlahson1||sumColumn!=sumAlahson2)
- return false;
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement