int[,] arr = new int[5, 5];
Console.WriteLine("向陣列中輸入元素: ");
for (int i = 0; i < 5; i++)
for (int j = 0; j < 5; j++)
arr[i, j] = int.Parse(Console.ReadLine());
Console.WriteLine("主對角線的元素值依次為: ");
for (int i = 0; i < 5; i++)
{
int j = i;
Console.Write("{0}\t", arr[i, j]);
}
Console.WriteLine();
Console.WriteLine("輔對角線的元素值依次為: ");
for (int i = 0; i < 5; i++)
{
int j = 4 - i;
Console.Write("{0}\t", arr[i, j]);
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/283944.html
標籤:疑難問題
上一篇:學生黨,求大佬幫助!!!