1. 程式人生 > >深入。NET平臺和C#程式設計 第二章課後練習 購物 + 加分

深入。NET平臺和C#程式設計 第二章課後練習 購物 + 加分

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

namespace 深入.NET平臺_第二章課後練習_購物
{
    class Program
    {
        static void Main(string[] args)
        {

            
            Console.WriteLine("請輸入原價:");
            int i = Convert.ToInt32(Console.ReadLine());
            int a = 0;
            if (i >= 100)
            {
                a = i - 50;
            }
            else {
                a = i;
            }
           
            Console.WriteLine("  原價       後來價格");

            Console.WriteLine("          " +i + "            " + a);
            
           
            Console.ReadLine();
        }
    }
}

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

namespace 深入.NET平臺_第二章課後練習
{
    class Program
    {
        static void Main(string[] args)
        {


            int[] points = new int[3];
            int[] newPoints = new int[3];
            Console.WriteLine("提分前:");
            for (int i = 0; i < points.Length; i++)
            {
                Console.WriteLine("第" + (i + 1) + "位成績");
                points[i] = Convert.ToInt32(Console.ReadLine());


            }
            //陣列複製
            for (int i = 0; i < points.Length; i++)
            {
                newPoints[i] = points[i];

                newPoints[i] = newPoints[i] + 5;

            }
            Console.WriteLine("\n 序號       提分前        提分後");
            for (int i = 0; i < points.Length; i++)
            {
                Console.WriteLine((i + 1) + "            " + points[i] + "            " + newPoints[i]);
            }
            Console.ReadLine();

        }
    }
}

相關推薦

no