• Предмет: Информатика
  • Автор: UAGamesTactics
  • Вопрос задан 6 лет назад

Срочно! Написать программу на С#. Дана матрица размера m*n. Найти количество строк и столбцов, которые монотонно возрастают и убывают.

Ответы

Ответ дал: DarkWep
0

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text.RegularExpressions;

namespace Math

{

   public class Program

   {

       public static void Main(string[] args)

       {

       bool yes=true;

       string s = "";

       int q = 0;

       int M, N;

       Console.WriteLine("Введите m:");    

       M = int.Parse(Console.ReadLine());

       Console.WriteLine("Введите n:");

       N = int.Parse(Console.ReadLine());

       int[,] m = new int[M,N];

       for (int i = 0; i < M; i++)  

       {

           for (int j = 0; j < N; j++)

           {

               Console.Write("[{0},{1}] : ",i,j);

               m[i, j] = int.Parse(Console.ReadLine());

               s += m[i, j] + "t";

           if (yes & m[i, 0] != m[i, j]) yes = false;

           }

           if (yes) q++;

           s += "n";

           yes = true;

       }

       Console.WriteLine(s+"nответ : "+q+" строк");

       Console.ReadKey(true);

       }

   }

}



Вас заинтересует