第三週C#技術支持訓練(二)自定義一個整數,輸出該數分別於1-10相乘的結果

實驗簡述:

2.        自定義一個整數,輸出該數分別於1-10相乘的結果。(使用\t控制輸出格式)

源代碼:

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

namespace Consoletest1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("請輸入一個整數:");
            string str = Console.ReadLine();
            int n = int.Parse(str);
            for (int i = 1; i <= 10; i++)
            {
                int m = n * i;
                Console.WriteLine("相乘後的數爲:" + m + "\t");


            }
            Console.ReadLine();


        }
    }
}

輸出結果:

經驗總結:
 Console.WriteLine("相乘後的數爲:" + m + "\t");與 Console.WriteLine("相乘後的數爲:{0}",m);的區別

 

發佈了122 篇原創文章 · 獲贊 80 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章