开发者

How do I display my input on the correct coord on my two dimensional array?

开发者 https://www.devze.com 2023-03-14 17:36 出处:网络
I am making a two dimensional array (soccer matrix)I have already made my arrays, datacolumn and rows.

I am making a two dimensional array (soccer matrix)I have already made my arrays, datacolumn and rows. But the hard part for me now is to get them in my output on the correct spot.

My first problem

//Hometeams are the rows and the away teams are the columns.
Console.WriteLine("Insert hometeam");
Console.Writeline("Insert awayteam");
Console.WriteLine("Now fill in the score of the match or the date of the match");

So the first two we have to read, and the last one we read and display. Tricky part is that I don't know how to set my two dimensional array like I do down here with the correct input underneath it. So I kinda need to read the coord of the rows and the coord of the columns seperately and display it.

             England   Germany   Holland   Spain   Germany   Russia   Japan

England         x

Germany                    x

Holland                             x

Spain                                         x

Germany                                               x

Russia                                                          x

Japan                                                                    x

So How do I read my input and then display it on my two dimensional array?

My second problem

My columns are a bit overlapping on top of my rows, like so:

 England   Germany   Holland   Spain   Germany   Russia   Japan

England         

Germany                    

Holland                             

Spain                                         

Germany                                               

Russia                                                          

Japan                                                                    

Is there perhaps a way to give every array a size in pixels? ( don't even know if thats possible). Mabye this will fix it. Or does someone have any other suggestion?

This all will be made into a console application.

Best regards,

Answer to a question (This my code At this moment)

DataTable Matrix = new DataTable();
Matrix.TableName = "Matrix";
Matrix.Columns.Add(new DataColumn("Ado", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("Ajax", System.Type.GetType("System.String")));  
Matrix.Columns.Add(new DataColumn("AZ", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("FC-GR", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("FC-TW", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("FC-U", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("Fey", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("Her", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("Nac", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("PSV", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("开发者_高级运维RKC", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("ROD", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("SC", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("Spa", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("Vit", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("VVV", System.Type.GetType("System.String")));
Matrix.Columns.Add(new DataColumn("WIL", System.Type.GetType("System.String")));


Matrix.Rows.Add("Ado Den Haag", System.Type.GetType("System.String"));
Matrix.Rows.Add("Ajax", System.Type.GetType("System.String"));
Matrix.Rows.Add("AZ", System.Type.GetType("System.String"));
Matrix.Rows.Add("FC Groningen", System.Type.GetType("System.String"));
Matrix.Rows.Add("FC Twente", System.Type.GetType("System.String"));
Matrix.Rows.Add("FC Utrecht", System.Type.GetType("System.String"));
Matrix.Rows.Add("Feyenoord", System.Type.GetType("System.String"));
Matrix.Rows.Add("Hercules Almelo", System.Type.GetType("System.String"));
Matrix.Rows.Add("NAC Breda", System.Type.GetType("System.String"));
Matrix.Rows.Add("PSV", System.Type.GetType("System.String"));
Matrix.Rows.Add("RKC Waalwijk", System.Type.GetType("System.String"));
Matrix.Rows.Add("Roda JC", System.Type.GetType("System.String"));
Matrix.Rows.Add("SC Heerenveen", System.Type.GetType("System.String"));
Matrix.Rows.Add("Sparta Rotterdam", System.Type.GetType("System.String"));
Matrix.Rows.Add("Vitesse", System.Type.GetType("System.String"));
Matrix.Rows.Add("VVV-Venlo", System.Type.GetType("System.String"));
Matrix.Rows.Add("Willem II", System.Type.GetType("System.String"));

string[,] clubs = new string[20, 30];
  clubs[1,0] = "     ADO"; 
  clubs[2,0] = "     Ajax"; 
  clubs[3,0] = "     AZ";
  clubs[4,0] = "     FC-GR";
  clubs[5,0] = "     FC-TW";
  clubs[6,0] = "     FC-U";
  clubs[7,0] = "     FEY";
  clubs[8,0] = "     HER";
  clubs[9,0] = "     NAC";
  clubs[10,0] = "     NEC";
  clubs[11,0] = "     PSV";
  clubs[12,0] = "     RKC";
  clubs[13,0] = "     ROD";
  clubs[14,0] = "     SC";
  clubs[15,0] =  "    SPA";
  clubs[16,0] = "     VIT";
  clubs[17,0] = "     VVV";
  clubs[18,0] = "     WIL";


  clubs[0, 1] = "Ado Den haag";
  clubs[0, 2] = "Ajax";
  clubs[0, 3] = "AZ";
  clubs[0, 4] = "FC Groningen";
  clubs[0, 5] = "FC Twente";
  clubs[0, 6] = "FC Utrecht";
  clubs[0, 7] = "Feyenoord";
  clubs[0, 8] = "Hercules Almelo";
  clubs[0, 9] = "NAC Breda";
  clubs[0, 10] = "NEC";
  clubs[0, 11] = "PSV";
  clubs[0, 12] = "RKC Waalwijk";
  clubs[0, 13] = "Roda JC";
  clubs[0, 14] = "SC Heerenveen";
  clubs[0, 15] = "Sparta Rotterdam";
  clubs[0, 16] = "Vitesse";
  clubs[0, 17] = "VVV-Venlo";
  clubs[0, 18] = "Willem II";





            int rows = 15;
    int colums = 15;
    int x = 0;
    int y = 0;
            string str;
            int hometeam;
            int awayteam;

            Console.WriteLine("Select hometeam number");
            for (int i = 1; i < colums; i++)
            {
                Console.WriteLine(clubs[i, 0] + " " + i);
            }
            str = Console.ReadLine();
            hometeam = Int32.Parse(str);

            Console.WriteLine("select awayteam number");
            for (int i = 1; i < rows; i++)
            {
                Console.WriteLine(clubs[0, i] + " " + i);
            }
            str = Console.ReadLine();
            awayteam = Int32.Parse(str);

            Console.WriteLine("Write de score or date of the match");
            str = Console.ReadLine();
            clubs[hometeam, awayteam] = str;






            for (; y < rows; y++)
            {
                for (; x < colums; x++)
                {
                    Console.Write(clubs[x, y] + " ");
                    if (x == (colums - 1))
                    {
                        Console.WriteLine("");
                        Console.WriteLine("");
                    }
                }
                x = 0;
            }

            Console.ReadLine();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号