Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#10
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- 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());
- }
- static void Main(string[] args)
- {
- int[,] a = new int[2, 2];
- KeletMatrix(a);
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- if (a[i, j] < j)
- a[i, j] += j;
- else if (a[i, j] == j)
- a[i, j] -= i * j;
- else
- a[i, j] /= a[j, i];
- }
- }
- PrintMatrix(a);
- }
- }
- }
- //#11
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- 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());
- }
- static void CreateMagicSquare(int[,] a)
- {
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- a[i, j] = 1;
- int num = 3, x = a.GetLength(1) - 1, y = a.GetLength(1)/2;
- a[x, y] = 2;
- x--;
- if (x < 0)
- x = a.GetLength(0) - 1;
- y--;
- if (y < 0)
- y = a.GetLength(1) - 1;
- if (a[x, y] != 1) {
- a[x, y] =
- }
- }
- static void Main(string[] args)
- {
- int[,] a = new int[2, 2];
- }
- }
- }
- //#12
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- 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());
- }
- static void Main(string[] args)
- {
- int[,] a = new int[2, 2];
- KeletMatrix(a);
- bool latin = true;
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- for (int k = j + 1; k < a.GetLength(1); k++)
- if (a[i, j] == a[i, k])
- latin = false;
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- for (int k = i + 1; k < a.GetLength(0); k++)
- if (a[i, j] == a[k, j])
- latin = false;
- Console.WriteLine(latin);
- }
- }
- }
- //#13
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- 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 int BiggestInRow(int[,] a, int rowNum)
- {
- int max = a[rowNum, 0], k = 0;
- for (int i = 1; i < a.GetLength(1); i++)
- if (max < a[rowNum, i])
- {
- max = a[rowNum, i];
- k = i;
- }
- //Console.WriteLine(k);
- return k;
- }
- static void Main(string[] args)
- {
- int[,] a = new int[5, 5];
- Random rnd = new Random();
- for (int i = 0; i < a.GetLength(0); i++)
- for (int j = 0; j < a.GetLength(1); j++)
- a[i, j] = rnd.Next(160, 191);
- int holder;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- holder = a[i, i];
- int location = BiggestInRow(a, i);
- a[i, i] = a[i, location];
- a[i, location] = holder;
- }
- int max = a[0, 0], k = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- if (a[i, i] > max)
- {
- max = a[i, i];
- k = i;
- }
- }
- holder = a[0, 4]; //I assumed this is mishbezet 1,5 since there is no [1, 5]
- a[0, 4] = a[k, k];
- a[k, k] = holder;
- PrintMatrix(a);
- }
- }
- }
Add Comment
Please, Sign In to add comment