主要是循环嵌套循环,还有条件上的细微控制
刚开始是写成 i 跟 j 都是小于等于9的,非常不好看,稍微坑了,后来改了一下
用 i 来控制 j 这样就好看多了
还有一个要点就是占位符: " " ,这个的运用还有制表符的运用: "\t"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace 训练1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("九九乘法表:" + "<br>");
for (int i = 1; i <= 9; i++)
{
Response.Write("<br>");
for (int j = 1; j <= i; j++)
{
Response.Write(i + "*" + j + "="+i * j+"\t" + " "+" "+ " ");
}
}
}
}
}
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("九九乘法表:" + "<br>");
for (int i = 1; i <= 9; i++)
{
Response.Write("<br>");
for (int j = 1; j <= i; j++)
{
Response.Write(i + "*" + j + "="+i * j+"\t" + " "+" "+ " ");
}
}
}
}
}
下面是效果图,虽然还是有些不太整齐,还是创建表格,放到表格里面会比较好