using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace choice
{
class Program
{
static void Main(string[] args)
{
int count=0;
int sum = 0;
int[] sort = new int[10];
for (int i = 0; i < 10; i++)
{
sort[i] = i + 1;
}
for (int j = 0; j < 10&&sum<9; j++)
{
if (sort[j] != 0)
{
Console.WriteLine(sort[j]);
count = (count + 1) % 3;
if (count == 0)
{
sort[j] = 0;
sum+=1;
}
}
if (j == 9)
{
j =-1;
}
}
for (int n = 0; n < 10; n++)
{
if (sort[n] != 0)
Console.Write(sort[n]);
Console.WriteLine();
}
Console.ReadKey();
}
}
}
本文通过一个简单的 C# 程序演示了如何初始化数组、遍历数组并进行特定条件下的元素移除。该示例展示了基本的数组操作技巧,包括使用 for 循环填充数组、打印数组元素以及根据条件移除数组中的某些元素。
9597

被折叠的 条评论
为什么被折叠?



