C#第三章上机3

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int er, op;
            data s = new data();
            s.slldata();
            int[] i = s.slldata();
            for (int j = 0; j < i.Length;j++ )
                Console.WriteLine(i[j]);

            int name1 = 0;
            int name2 = 0;
            s.Gett(ref name1,ref name2);
        
            Console.WriteLine("奇数的个数是:{0},偶数的个数是:{1}",name1 ,name2);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class data
    {
        int er, op;
        public int[] slldata() {
            int[] array = new int[30];
            array[0] = 1;
            array[1] = 1;
            for (int i = 2; i < 30; i++) {
                array[i] = array[i - 1] + array[i - 2];
         }
            return array;
        }
        public void Gett(ref int er, ref int op) {
            int[] array = slldata();
            foreach (int ted in array) {
                if (ted % 2 == 0)
                {
                    er++;
                }
                else {
                    op++;
                }
            
            
            }
        }


    }
}

你可能感兴趣的:(C#第三章上机3)