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 ConsoleApplication2
- {
- class Program
- {
- static bool Dlila(int[,] matrix, int total)
- {
- bool ok = true;
- double avg;
- int counterperline;
- int counterall = 0;
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- counterperline = 0;
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- if (matrix[i, j] != 0)
- {
- counterall++;
- counterperline++;
- }
- }
- if (counterperline > 2)
- ok = false;
- }
- avg = (double)total * 0.2;
- if (counterall > avg)
- ok = false;
- return ok;
- }
- static void Main(string[] args)
- {
- Console.Write("Size of the matrix: ");
- int n = int.Parse(Console.ReadLine());
- int[,] matrix = new int[n, n];
- Random R = new Random();
- for (int i = 0; i < matrix.GetLength(0); i++)
- {
- for (int j = 0; j < matrix.GetLength(1); j++)
- {
- matrix[i, j] = int.Parse(Console.ReadLine());
- }
- Console.WriteLine();
- }
- bool ok = Dlila(matrix, (n * n));
- Console.Write(ok);
- Console.ReadKey();
- }
- }
- }
Add Comment
Please, Sign In to add comment