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 Program
- {
- static void Main(string[] args)
- {
- /*
- * Определить номера строк прямоугольной матрицы, хотя бы один элемент которых равен c, и элементы этих строк умножить на d.
- */
- Console.WriteLine("Введите размеры прямоугольной матрицы : ");
- int x = Convert.ToInt16(Console.ReadLine());
- int y = Convert.ToInt16(Console.ReadLine());
- int[,] M = new int[x, y];
- Random random = new Random();
- int rand;
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- rand = random.Next(0, 100);
- M[i, j] = rand;
- }
- }
- Console.WriteLine("Исходная матрица: ");
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- Console.Write(M[i, j] + "\t");
- }
- Console.WriteLine();
- }
- Console.Write("c : ");
- int c = Convert.ToInt16(Console.ReadLine());
- Console.Write("d : ");
- int d = Convert.ToInt16(Console.ReadLine());
- Console.WriteLine("Номера строк,в которых хотя бы один элемент равен c: ");
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- if (M[i,j] == c)
- {
- for(int t = 0; t<y;t++)
- {
- M[i, t] *= d;
- }
- Console.WriteLine(i + 1);
- break;
- }
- }
- }
- Console.WriteLine("Полученная матрица: ");
- for (int i = 0; i < x; i++)
- {
- for (int j = 0; j < y; j++)
- {
- Console.Write(M[i, j] + "\t");
- }
- Console.WriteLine();
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement