Example #1
0
 public void insertArray(LinkedList list, square_matrix X, int[] splitted)
 {
     X.array = new int[X.getDimension(), X.getDimension()];
     for (int i = 0; i < X.getDimension(); i++)
     {
         for (int j = 0; j < X.getDimension(); j++)
         {
             X.array[i, j] = splitted[i * X.getDimension() + j];
         }
     }
     list.Add(X);
 }
Example #2
0
        static LinkedList input(StreamReader reader)
        {
            LinkedList list = new LinkedList();
            string     String, word = "";
            int        charInString = 0, inputStrings = 0;

            while ((String = reader.ReadLine()) != null)
            {
                if (String.Length != 0)
                {
                    inputStrings++;
                }

                for (int i = 0; i < String.Length; i++)
                {
                    if (String[0] == '/')
                    {
                        inputStrings--;
                        break;
                    }

                    if (Char.IsDigit(String[i]) && String[i] != 's' && String[i] != 'd' && String[i] != 't')
                    {
                        word        += String[i];
                        word        += ";";
                        charInString = charInString + 2;
                    }
                    else
                    {
                        word = word.Remove(charInString - 1);
                        int[] splitted = word.Split(';').Select(int.Parse).ToArray();

                        if (String[i] == 't')
                        {
                            int lengthCounter = 0;
                            int t             = 1;
                            for (int s = splitted.Length; s > 0; s = s - t)
                            {
                                lengthCounter++;
                                t++;
                            }

                            triangle_matrix X = new triangle_matrix(lengthCounter);
                            X.insertArray(list, X, splitted);
                        }
                        if (String[i] == 'd')
                        {
                            diagonal_matrix X = new diagonal_matrix(splitted.Length);
                            X.insertArray(list, X, splitted);
                        }
                        if (String[i] == 's')
                        {
                            square_matrix X = new square_matrix(inputStrings);
                            X.insertArray(list, X, splitted);
                        }

                        word         = "";
                        inputStrings = 0;
                        charInString = 0;
                    }
                }
            }
            return(list);
        }