• 求约束------------------------ do while循环 算法思想


    前段代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
         <h2>求2到200之间任意一个数的约数</h2>
       <br/>
        输入任意一个数字:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br/>
            <asp:Button ID="Button" runat="server" Text="取余" onclick="Button_Click" />
            <br/>
            <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        </div>
        </form>
    </body>
    </html>
    

      后端代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button_Click(object sender, EventArgs e)
        {
            int yueshu;
            int i=1;
            string temp = "";
    
            yueshu = int.Parse(TextBox1.Text);
            do
            {
                if (yueshu % i == 0) 
                {
                   temp += " "+i;
                }
                i++;
            } while (i<=yueshu);
    
            Label1.Text = temp; 
        }
    }
    

      

  • 相关阅读:
    理解协方差矩阵
    混合高斯模型(Gaussian mixture model, GMM)
    简单理解EM算法Expectation Maximization
    Sigmoid函数与Softmax函数的理解
    关于交叉熵损失函数Cross Entropy Loss
    进制转换 -- 牛客
    首字母大写--牛客
    最简真分数
    剩下的数 -- 牛客
    N的阶乘 -- 牛客
  • 原文地址:https://www.cnblogs.com/sunyubin/p/9675212.html
Copyright © 2020-2023  润新知