Advertisement
ElliasBLR

Vitaly 4

Oct 27th, 2020
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             /*
  13.              * Определить номера строк прямоугольной матрицы, хотя бы один элемент которых равен c, и элементы этих строк умножить на  d.
  14.              */
  15.             Console.WriteLine("Введите размеры прямоугольной матрицы : ");
  16.             int x = Convert.ToInt16(Console.ReadLine());
  17.             int y = Convert.ToInt16(Console.ReadLine());
  18.             int[,] M = new int[x, y];
  19.            
  20.  
  21.  
  22.             Random random = new Random();
  23.             int rand;
  24.  
  25.             for (int i = 0; i < x; i++)
  26.             {
  27.                 for (int j = 0; j < y; j++)
  28.                 {
  29.                     rand = random.Next(0, 100);
  30.                     M[i, j] = rand;
  31.                 }
  32.             }
  33.             Console.WriteLine("Исходная матрица: ");
  34.             for (int i = 0; i < x; i++)
  35.             {
  36.                 for (int j = 0; j < y; j++)
  37.                 {
  38.                     Console.Write(M[i, j] + "\t");
  39.                 }
  40.                 Console.WriteLine();
  41.             }
  42.             Console.Write("c : ");
  43.             int c = Convert.ToInt16(Console.ReadLine());
  44.             Console.Write("d : ");
  45.             int d = Convert.ToInt16(Console.ReadLine());
  46.  
  47.             Console.WriteLine("Номера строк,в которых хотя бы один элемент равен c: ");
  48.  
  49.             for (int i = 0; i < x; i++)
  50.             {
  51.                 for (int j = 0; j < y; j++)
  52.                 {
  53.                    if (M[i,j] == c)
  54.                     {
  55.                         for(int t = 0; t<y;t++)
  56.                             {
  57.                             M[i, t] *= d;
  58.                             }
  59.  
  60.                         Console.WriteLine(i + 1);
  61.                         break;
  62.                     }
  63.                 }
  64.                
  65.             }
  66.            
  67.             Console.WriteLine("Полученная матрица: ");
  68.             for (int i = 0; i < x; i++)
  69.             {
  70.                 for (int j = 0; j < y; j++)
  71.                 {
  72.                     Console.Write(M[i, j] + "\t");
  73.                 }
  74.                 Console.WriteLine();
  75.             }
  76.  
  77.             Console.ReadKey();
  78.  
  79.         }
  80.  
  81.  
  82.  
  83.  
  84.  
  85.     }
  86.  
  87.     }
  88.  
  89.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement