【如何通过二维数组存储四大名著及作者名称?】
关键代码:
static void Main(string[] args)
{
string[,] book = { { "《三国演义》", "罗贯中" },{ "《水浒传》", "施耐庵" },{ "《西游记》", "吴承恩" },{ "《红楼梦》", "曹雪芹" } };
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 2; j++)
{
Console.Write(book[i,j]);
}
Console.WriteLine();
}
Console.ReadKey();
}
评论