- namespace ConsoleApplication5
- {
- class Program
- {
- static void Main(string[] args)
- {
- Function(1, 2, 3, 4, 5, 6, 7, 0, -1);
- Console.ReadLine();
- }
- static void Function(params int[] a)
- {
- for (int i = 0; i < a.Length; i++)
- {
- if (a[i]>0)
- {
- a[i] += 1;
- }
- else if (a[i]<0)
- {
- a[i] -= 1;
- }
- else if(a[i]==0)
- {
- a[i] = a[i];
- }
- }
- foreach (var item in a)
- {
- Console.WriteLine(item);
- }
- }
- }
- }
复制代码
慢慢理解吧,注释就不写了 |