int[] array02 = { 3, -21, 0, 44, -2, 33, -12 };
for (int i = 0; i < array02.Length; i++)
{
if (array02[i] > 0)
{
array02[i]++;
}
if (array02[i] < 0)
{
array02[i]--;
}
}
for (int i = 0; i < array02.Length; i++)
{
Console.WriteLine(array02[i] + " ");
}
C#遇到数组中小于0的减一,大于0的加一,等于0不变
最新推荐文章于 2022-09-21 20:24:51 发布