Example #1
0
        private void printInFile(TPR table)
        {
            int[,] Rank  = new int[RowIndex, ColumnIndex];
            int[,] Value = new int[RowIndex, ColumnIndex];
            table.CopyRank(ref Rank);
            table.CopyValue(ref Value);
            using (StreamWriter output = new StreamWriter(@"C:\Users\Lera\source\repos\CW5\Part2\result.txt", false, System.Text.Encoding.Default)) {
                for (int i = 0; i < RowIndex; i++)
                {
                    for (int j = 0; j < ColumnIndex; j++)
                    {
                        output.Write($"оценка:{Value[i, j]} ранг:{Rank[i, j]} ");
                    }
                    output.WriteLine();
                }
            }

            /*    using (StreamWriter output = new StreamWriter(@"C:\Users\Lera\source\repos\CW5\Part2\resultSort.txt", false, System.Text.Encoding.Default))
             *
             *  {
             *      for (int rank = 1; rank <= RowIndex; rank++)
             *          for (int j = 0; j < RowIndex; j++)
             *          {
             *              if (Rank[j, ColumnIndex - 1] == rank)
             *
             *              {
             *                  int res = j + 1;
             *                  output.WriteLine($"{res}");
             *              }
             *          }
             *  }*/
        }
Example #2
0
        private void printRank(TPR table)
        {
            int[,] Rank = new int[RowIndex, ColumnIndex];
            table.CopyRank(ref Rank);
            Form2 f2 = new Form2();

            f2.dataGridView1.ColumnCount = ColumnIndex + 1;
            f2.dataGridView1.RowCount    = RowIndex + 1;

            for (int i = 0; i < ColumnIndex; i++)
            {
                f2.dataGridView1.Columns[i].HeaderText = $"P{i}";
                for (int j = 0; j < RowIndex; j++)
                {
                    f2.dataGridView1.Rows[j].HeaderCell.Value = $"{j + 1}";
                    f2.dataGridView1.Rows[j].Cells[i].Value   = Rank[j, i];
                }
            }
            f2.dataGridView2.RowCount = RowIndex + 1;
            f2.dataGridView2.Columns[0].HeaderText = "ранжировка";

            for (int rank = 1; rank <= RowIndex; rank++)
            {
                for (int j = 0; j < RowIndex; j++)
                {
                    if (Rank[j, ColumnIndex - 1] == rank)
                    {
                        f2.dataGridView2.Rows[rank - 1].Cells[0].Value = j + 1;
                    }
                }
            }

            f2.ShowDialog();
            printInFile(table);
        }