【程式設計-C#】九九乘法表
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace 九九乘法表 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string output = ""; //用來儲存要輸出的資料 for (int i = 1; i <= 9; i++) { for (int j = 1; j <= 9; j++) { output += "" + i + "*" + j + "=" + (i * j).ToString().PadLeft(2, ' ') + " "; } output += "rn"; //每印完一列,進行跳行(r:return, n:new line) } label1.Text = output; //將output內容輸出到label1上 } } }