Advertisement
radidim

matrix (C# Shell App Paste)

Apr 3rd, 2021
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.  
  15.             var size = Console.ReadLine().Split().Select(int.Parse).ToArray();
  16.             var matrix = new int[size[0], size[1]];
  17.             for (int r = 0; r < size[0]; r++)
  18.             {
  19.                 var row = Console.ReadLine().Split().Select(int.Parse).ToArray();
  20.                 for (int c = 0; c < size[1]; c++)
  21.                 {
  22.                     matrix[r, c] += row[c];
  23.                 }
  24.  
  25.             }
  26.  
  27.             foreach (var item in matrix)
  28.             {
  29.                 Console.Write(item);
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement