Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- namespace ConsoleApplication1
- {
- class ForEachTest
- {
- static void InputArray(out int[,] a)
- {
- Console.Write("Enter count string of massiv: ");
- int n = int.Parse(Console.ReadLine());
- Console.Write("Enter count column of massiv: ");
- int m = int.Parse(Console.ReadLine());
- a = new int[n, m]; // объявление массива
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- Console.Write("a[{0},{1}]= ", i, j);
- a[i, j] = int.Parse(Console.ReadLine());
- }
- }
- }
- static string CheckConditions(int[,] a)
- {
- int len = a.GetLength(0);
- for (int i = 0; i < len; i++)
- {
- int sum = 0;
- for (int j = 0; j < len; j++)
- {
- if (a[i, j] > 0)
- {
- sum++;
- }
- }
- if (sum == len)
- {
- return "Massiv has a string with positive elements only";
- }
- }
- return "Massiv hasn't a string with positive elements only";
- }
- static void Main()
- {
- int[,] a;
- InputArray(out a);
- Console.WriteLine(CheckConditions(a));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement