自己闲来没事写了个九九乘法表 ,新手入门。大家看看就好。
自己闲来没事写了个九九乘法表 ,新手入门。

1 @using WebApp_Mvc_Wg_Api.Controllers; 2 @{ 3 ViewBag.Title = "九九乘法表"; 4 //Layout = "~/Views/Shared/_Layout.cshtml"; 5 } 6 <style> 7 .main { 8 width: 1000px; 9 height:190px; 10 } 11 12 .main li { 13 float: left; 14 width: 100px; 15 list-style: none; 16 } 17 </style> 18 <h2>@ViewBag.Title</h2> 19 20 <div class="main"> 21 @{ 22 List<string> cf_list = ViewData["chenfabiao"] as List<string>; 23 } 24 <ul> 25 @foreach (var item in cf_list) 26 { 27 <li>@item.ToString()</li> 28 } 29 </ul> 30 </div> 31 32 <hr /> 33 34 <h2>九九加法表</h2> 35 36 <div class="main"> 37 @{ 38 List<string> jf_list = ViewData["jiafabiao"] as List<string>; 39 } 40 <ul> 41 @foreach (var item in jf_list) 42 { 43 <li>@item.ToString()</li> 44 } 45 </ul> 46 </div>

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.Mvc; 6 7 namespace WebApp_Mvc_Wg_Api.Controllers 8 { 9 public class DemoController : Controller 10 { 11 // GET: Demo 12 public ActionResult Index() 13 { 14 return View(); 15 } 16 public ActionResult chenfabiao() 17 { 18 jiafabiao(); 19 20 List<string> list = new List<string>(); 21 for (int x = 1; x <= 9; x++) 22 { 23 for (int y = 1; y <= 9; y++) 24 { 25 string formula = y + " * " + x + " = " + (x * y); 26 formula = y > x ? " 焱 " : formula; 27 list.Add(formula); 28 } 29 } 30 ViewData["chenfabiao"] = list.ToList(); 31 return View(ViewData["chenfabiao"]); 32 } 33 34 public ActionResult jiafabiao() 35 { 36 List<string> list = new List<string>(); 37 for (int x = 1; x <= 9; x++) 38 { 39 for (int y = 1; y <= 9; y++) 40 { 41 string formula = y + " + " + x + " = " + (x +y); 42 formula = y > x ? " 焱 " : formula; 43 list.Add(formula); 44 } 45 } 46 ViewData["jiafabiao"] = list.ToList(); 47 return View(ViewData["jiafabiao"]); 48 } 49 50 } 51 }
页面结构
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?