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;
- using System.Threading.Tasks;
- namespace lab_13_ex_3
- {
- class Program
- {
- static void fill(int[,] a)
- {
- Random R = new Random();
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- a[i, j] = R.Next(1);
- }
- }
- }
- static void output(int[,] a)
- {
- Console.WriteLine("____________________________________________");
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- Console.Write(a[i, j] + " ");
- }
- Console.WriteLine("");
- }
- Console.WriteLine("____________________________________________");
- }
- static void output(int [] a)
- {
- Console.WriteLine("____________________________________________");
- for (int i = 0; i < a.Length; i++)
- {
- Console.Write(a[i] + " ");
- }
- Console.WriteLine("");
- Console.WriteLine("____________________________________________");
- }
- static void form1(int N, int[,] a, int[] b)
- {
- int count = 0;
- int count1 = 0;
- for (int i = 0; i < a.GetLength(1); i++)
- {
- for (int j = 0; j < a.GetLength(0); j++)
- {
- if (a[j,i] > N)
- {
- count++;
- }
- if(j == a.GetLength(0) - 1)
- {
- b[count1] = count;
- count = 0;
- count1++;
- }
- }
- }
- }
- static void form2(int N, int[,] a, int[] b)
- {
- int sum = 0;
- int count1 = 0;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- for (int j = 0; j < a.GetLength(1); j++)
- {
- if(a[i,j] < N)
- {
- sum += a[i, j];
- }
- if (j == a.GetLength(0) - 1)
- {
- b[count1] = sum;
- sum = 0;
- count1++;
- }
- }
- }
- }
- static void form3(int [,] a, int [] b)
- {
- int count = 0;
- bool f1 = true;
- int c;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- f1 = true;
- c = a[i, 0];
- for (int j = 0; j < a.GetLength(1); j++)
- {
- if (c != a[i, j])
- {
- f1 = false;
- }
- if (j == a.GetLength(1) - 1 && f1)
- {
- b[count] = i + 1;
- count++;
- }
- }
- }
- }
- static int form3_count(int[,] a)
- {
- int count = 0;
- bool f1 = true;
- int c;
- for (int i = 0; i < a.GetLength(0); i++)
- {
- f1 = true;
- c = a[i, 0];
- for (int j = 0; j < a.GetLength(1); j++)
- {
- if(c != a[i, j])
- {
- f1 = false;
- }
- if(j == a.GetLength(1) - 1 && f1)
- {
- count++;
- }
- }
- }
- return count;
- }
- static void Main(string[] args)
- {
- int N = 5;
- int[] b = new int[N];
- int[] c = new int[5];
- int[,] a = new int[N,N];
- int[] d = new int[form3_count(a)];
- fill(a);
- output(a);
- form1(65, a, b);
- output(b);
- form2(65, a, c);
- output(c);
- form3(a, d);
- output(d);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement