Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace LangProgKT3
- {
- class Matrix
- {
- protected internal int[,] array;
- private int N;
- protected internal Matrix(int n=10)
- {
- var random = new Random();
- this.array = new int[n, n];
- this.N = n ;
- for (int i = 0; i < n; i++)
- for (int j = 0; j < n; j++)
- this.array[i, j] = random.Next(-10, 10);
- }
- protected internal void print()
- {
- for (int i = 0; i < this.N; i++)
- {
- for (int j = 0; j < this.N; j++)
- Console.Write(this.array[i,j] + " ");
- Console.WriteLine();
- }
- }
- protected internal void fill_zero()
- {
- for (int i = 0; i < this.N/2; i++)
- {
- for (int j = 0; j < this.N / 2; j++)
- if (this.array[i, j] < 0) this.array[i, j] = 0;
- }
- }
- protected internal void fill_one()
- {
- for (int i = this.N / 2; i < this.N ; i++)
- {
- for (int j = this.N / 2; j < this.N ; j++)
- if (this.array[i, j] > 0) this.array[i, j] = 1;
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Matrix matrix = new Matrix(8);
- matrix.print();
- Console.WriteLine();
- matrix.fill_one();
- matrix.fill_zero();
- matrix.print();
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement