int[] arr=new int[11];
//遍历数组并输入11个元素
for (int i = 0; i < arr.Length; i++)
{
Console.WriteLine("请输入第{0}个数:",i+1);
arr[i] = Convert.ToInt32(Console.ReadLine());
}
//输出下标为偶数的元素
Console.WriteLine("偶数元素为:");
for (int y = 0; y <arr.Length; y++)
{
if (y % 2 == 0)
{
Console.WriteLine("当前元素下标为:"+y+",元素值为:"+arr[y]);
}
}
//输出下标为奇数的元素
Console.WriteLine("奇数元素为:");
for (int z = 0; z < arr.Length; z++)
{
if (z % 2 != 0)
{
Console.WriteLine("当前元素下标为:" + z + ",元素值为:" + arr[z]);
}
}
Console.ReadKey();
运行结果: