1. 程式人生 > >深入.net和C#程式設計第二章上機練習1

深入.net和C#程式設計第二章上機練習1

namespace PointsAPP
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] points = new int[5];  //歷史積分陣列
            int[] newPoints = new int[5]; //新年積分陣列
            Console.WriteLine("請輸入5位會員的積分");
            for (int i = 0; i < points.Length; i++)
            {
                Console.Write("第" + (i + 1) + "位會員積分:");
                points[i] = Convert.ToInt32(Console.ReadLine());
            }
            //陣列複製
            for (int i = 0; i < points.Length; i++)
            {
                newPoints[i] = points[i];
                newPoints[i] = newPoints[i] + 500; //贈送500積分
            }
            Console.WriteLine("\n序號  歷史積分  新年積分");
            //迴圈輸出兩個年度的積分
            for (int i = 0; i < points.Length; i++) {
                Console.WriteLine((i+1)+"\t"+points[i]+"\t"+newPoints[i]);
            }