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;
- namespace ConsoleApplication1
- {
- class submatrix
- {
- private int row;
- private int col;
- private int[,] mat;//= new int[ row, col];
- public submatrix(int row, int col)
- {
- this.row = row;
- this.col = col;
- this.mat = new int[row, col];
- }
- public void Build(int a)
- {
- Random rnd = new Random();
- for (int c = 0; c < col; c++)
- for (int r = 0; r < row; r++)
- mat[r, c] = rnd.Next(-a, a + 1);
- }
- public bool issubmatrix()
- {
- int k = 0;
- for (int r = 0; r < row; r++)
- for (int c = 0; c < col; c++)
- if (mat[r, c] != 0)
- k++;
- if (k < (row * col) / 2)
- return true;
- else
- return false;
- }
- public void print()
- {
- for (int r = 0; r < row; r++)
- {
- for (int c = 0; c < col; c++)
- {
- Console.Write("{0,5}", mat[r, c]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement