zoukankan      html  css  js  c++  java
  • 自己闲来没事写了个九九乘法表 ,新手入门。大家看看就好。

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

     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>
    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

    页面结构

  • 相关阅读:
    english note(6.3 to 6.8)
    english note(6.2 to 5.30)
    Lambda表达式
    Python Software Foundation
    eval(input())
    北航操作系统实验2019:Lab4-1代码实现参考
    北航操作系统实验2019:Lab4-1流程梳理
    面向对象设计与构造2019 第二单元总结博客作业
    面向对象设计与构造2019 第一单元总结博客作业
    Java代码度量分析工具:Designite简介
  • 原文地址:https://www.cnblogs.com/lvyezhiyou/p/7724654.html
Copyright © 2011-2022 走看看