Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#7
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- public static void PrintMatrix(int[,] a)
- {
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- Console.Write("{0,-7}", a[i, j]);
- Console.WriteLine();
- }
- }
- public static void KeletMatrix(int[,] a)
- {
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- a[i, j] = int.Parse(Console.ReadLine());
- }
- public static void KeletHad(int[] a)
- {
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- }
- public static int SumMatrix(int[,] a)
- {
- int sum = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- sum += a[i, j];
- return sum;
- }
- public static int SumRows(int[,] a, int rowNum)
- {
- int shum = 0;
- for (int i = 0; i < a.GetLength(1); i++)
- shum += a[rowNum, i];
- return shum;
- }
- public static int SumColumns(int[,] a, int columnNum)
- {
- int shum = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- shum += a[i, columnNum];
- return shum;
- }
- public static int BiggestInRow(int[,] a, int rowNum)
- {
- int max = a[rowNum, 0];
- for (int i = 1; i < a.GetLength(1); i++)
- if (max < a[rowNum, i])
- max = a[rowNum, i];
- return max;
- }
- public static bool MagicSquare(int[,] a)
- {
- bool magical = true;
- int shum = SumRows(a, 0);
- int i = 1;
- while (magical && i < a.GetLength(0))
- {
- magical = shum == SumRows(a, i);
- i++;
- }
- if (!magical)
- return magical;
- i = 0;
- while (magical && i < a.GetLength(1))
- {
- magical = shum == SumColumns(a, i);
- i++;
- }
- if (!magical)
- return magical;
- int shumA = 0;
- for (i = 0; i < a.GetLength(0); i++)
- shumA += a[i, i];
- if (shumA != shum)
- return false;
- shumA = 0;
- for (i = 0; i < a.GetLength(0); i++)
- shumA += a[i, a.GetLength(0) - i - 1];
- return shumA == shum;
- }
- static void Main(string[] args)
- {
- int[,] a = new int[40, 4];
- int[] memuzaim = new int[a.GetLength(0)];
- KeletMatrix(a);
- for (int i = 0; i < memuzaim.Length; i++)
- memuzaim[i] = SumRows(a, i);
- double memuza = 0;
- for (int i = 0; i < memuzaim.Length; i++)
- memuza += (double)memuzaim[i];
- memuza /= a.GetLength(0);
- Console.WriteLine(memuza);
- for (int i = 0; i < a.GetLength(1); i++)
- {
- Console.WriteLine(i);
- double memuza0 = 0;
- for (int j = 0; j < a.GetLength(0); j++)
- memuza0 += (double)a[j, i];
- memuza0 /= a.GetLength(0);
- Console.WriteLine(memuza0);
- }
- for (int i = 0; i < memuzaim.Length; i++)
- Console.WriteLine((double)memuzaim[i]-memuza);
- }
- }
- }
- //#10
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- public static void PrintMatrix(int[,] a)
- {
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- Console.Write("{0,-7}", a[i, j]);
- Console.WriteLine();
- }
- }
- public static void KeletMatrix(int[,] a)
- {
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- a[i, j] = int.Parse(Console.ReadLine());
- }
- public static void KeletHad(int[] a)
- {
- for (int i = 0; i < a.Length; i++)
- a[i] = int.Parse(Console.ReadLine());
- }
- public static int SumMatrix(int[,] a)
- {
- int sum = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- sum += a[i, j];
- return sum;
- }
- public static int SumRows(int[,] a, int rowNum)
- {
- int shum = 0;
- for (int i = 0; i < a.GetLength(1); i++)
- shum += a[rowNum, i];
- return shum;
- }
- public static int SumColumns(int[,] a, int columnNum)
- {
- int shum = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- shum += a[i, columnNum];
- return shum;
- }
- public static int BiggestInRow(int[,] a, int rowNum)
- {
- int max = a[rowNum, 0];
- for (int i = 1; i < a.GetLength(1); i++)
- if (max < a[rowNum, i])
- max = a[rowNum, i];
- return max;
- }
- public static bool MagicSquare(int[,] a)
- {
- bool magical = true;
- int shum = SumRows(a, 0);
- int i = 1;
- while (magical && i < a.GetLength(0))
- {
- magical = shum == SumRows(a, i);
- i++;
- }
- if (!magical)
- return magical;
- i = 0;
- while (magical && i < a.GetLength(1))
- {
- magical = shum == SumColumns(a, i);
- i++;
- }
- if (!magical)
- return magical;
- int shumA = 0;
- for (i = 0; i < a.GetLength(0); i++)
- shumA += a[i, i];
- if (shumA != shum)
- return false;
- shumA = 0;
- for (i = 0; i < a.GetLength(0); i++)
- shumA += a[i, a.GetLength(0) - i - 1];
- return shumA == shum;
- }
- static void Main(string[] args)
- {
- int[,] a = new int[30,30];
- KeletMatrix(a);
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- if (a[i, j] > )
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement