Matrix

in #ita6 days ago

using System;
using System.Collections.Generic;

public class Matrix{
public string input;
public Matrix(string input){
this.input = input;
}

public int[] Row(int row){
    List<int> parts = new List<int>();
    string [] intN = this.input.Split("\n");
    string [] elm = intN[row-1].Split(' '); 
    for(int i=0; i<elm.Length; i++){
        if(int.TryParse(elm[i], out int elmN)){
            parts.Add(elmN);
        }
    }
  return parts.ToArray();
}

public int[] Column(int col){
    List<int> parts = new List<int>();
    string [] intN = this.input.Split("\n");
    for(int i= 0; i<intN.Length; i++){
        string [] elmT = intN[i].Split(' ');
        if(int.TryParse(elmT[col-1], out int elm)){
            parts.Add(elm);
            }
    }
    return parts.ToArray();
}

}

Sort:  

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below

Congratulations @drago18121996! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You got more than 6500 replies.
Your next target is to reach 6750 replies.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Thank you for your witness vote!
Have a !BEER on me!
To Opt-Out of my witness beer program just comment STOP below