Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- /* Ситуативно, для чтения
- * foreach (int i in nums)
- {
- Console.WriteLine(i);
- }
- int[,] mas = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 }, { 10, 11, 12 } };
- int rows = mas.GetUpperBound(0) + 1;
- int columns = mas.Length / rows;
- // или так
- // int columns = mas.GetUpperBound(1) + 1;
- for (int i = 0; i < rows; i++)
- {
- for (int j = 0; j < columns; j++)
- {
- Console.Write(mas[i, j]);
- Console.Write("\t");
- }
- Console.WriteLine();
- }*/
- /* Задан массив действительных чисел размерности 10х10.Найти суммы элементов каждой строки, произведения элементов каждого столбца,
- * и максимальный элемент главной диагонали.*/
- var rnd = new Random();
- int[,] arr = new int[10, 10];
- int sum ;
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- {
- arr[i, j] = rnd.Next(1, 9);
- Console.Write(arr[i, j]);
- Console.Write("\t");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < 10; i++)
- {
- sum = 0;
- for (int j = 0; j < 10; j++)
- {
- sum += arr[i, j];
- }
- Console.WriteLine(" sum= " + sum);
- }
- int comp=1;
- for (int i = 0; i < 10; i++)
- {
- comp = 1;
- for (int j = 0; j < 10; j++)
- {
- comp*= arr[j, i];
- }
- Console.WriteLine(" composition= " + comp);
- }
- int a = 0;
- int b = 0;
- int max=0;
- for ( a = 0 , b=0; a < 9 && b<9; a++,b++)
- {
- if (arr[a,b] >arr [a+1,b+1] )
- {
- max = arr[a, b];
- arr[a, b] = arr[a + 1, b + 1];
- arr[a + 1, b + 1] = max;
- }
- }
- Console.WriteLine("maximum= "+arr[9,9]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement