using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApp4{ class You { public void Test( ref int[] vs) { if(vs==null||vs.Length==0) { Console.WriteLine("数组元素为零或者不存在,请重新输入:"); } else { for (int i = 0; i < vs.Length; i++) { if(i==2) { vs[i] = 3; } else { if (i < 2) { vs[i] = vs[i]; } else vs[i] = vs[i + 1]; } Console.WriteLine("输出数组元素分别是:{0}",vs[i]); } } } } class Program { static void Main(string[] args) { You you = new You(); int[] vs = {1,2,5,4,6}; you.Test(ref vs); Console.WriteLine("程序运行完毕!"); Console.ReadKey(); } }}
添加回答
举报
0/150
提交
取消