Advertisement
BloodMoonYTC

arraymultiply

Oct 24th, 2021
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace arrayszorzas
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             while (true)
  10.             {
  11.                 Console.Write("Sorok szama: ");
  12.                 int m = int.Parse(Console.ReadLine());
  13.                 Console.Write("Oszlopok szama: ");
  14.                 int n = int.Parse(Console.ReadLine());
  15.                 if (m == 0 || n == 0) break;
  16.                 int[,] mat = new int[m, n];
  17.                 Console.WriteLine("Matrix beolvasasa ");
  18.                 for (int i = 0; i < m; i++)
  19.                 {
  20.                     for (int j = 0; j < n; j++)
  21.                     {
  22.                         mat[i, j] = int.Parse(Console.ReadLine());
  23.                     }
  24.                 }
  25.                 Console.Write("Melyik szammal szorzod a matrix elemeit: ");
  26.                 int k = int.Parse(Console.ReadLine());
  27.                 for (int i = 0; i < m; i++)
  28.                 {
  29.                     for(int j = 0; j < n; j++)
  30.                     {
  31.                         mat[i, j] *= k;
  32.                     }
  33.                 }
  34.                 Console.WriteLine("A matrix kiirasa");
  35.                 for (int i = 0; i < m; i++)
  36.                 {
  37.                     for (int j = 0; j < n; j++)
  38.                     {
  39.                         Console.Write("{0}\t", mat[i, j]);
  40.                     }
  41.                     Console.Write("\n");
  42.                 }
  43.                 Console.WriteLine("Kolity Kristof");
  44.                 Console.ReadLine();
  45.  
  46.             }
  47.         }
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement