自己闲来没事写了个九九乘法表 ,新手入门。大家看看就好。_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > 自己闲来没事写了个九九乘法表 ,新手入门。大家看看就好。

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

 2017/10/24 18:55:58  柚子焦糖  程序员俱乐部  我要评论(0)
  • 摘要:自己闲来没事写了个九九乘法表,新手入门。1@usingWebApp_Mvc_Wg_Api.Controllers;2@{3ViewBag.Title="九九乘法表";4//Layout="~/Views/Shared/_Layout.cshtml";5}6<style>7.main{8width:1000px;9height:190px;10}1112.mainli{13float:left;14width:100px;15list-style:none;16}17<
  • 标签:大家 自己 新手

自己闲来没事写了个九九乘法表 ,新手入门。

class="code_img_closed" src="/Upload/Images/2017102418/0015B68B3C38AA5B.gif" alt="">
 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>
logs_code_collapse">View Code
 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 }
Controllers Code

页面结构

 

发表评论
用户名: 匿名