输入二个数n ,m 求 m内所有之和等于n

 Btnadd事件:

   string r = " ";
    int txt1 = Convert.ToInt32(sp_one.Text.Trim());
    int txt2 = Convert.ToInt32(sp_two.Text.Trim());
    faf(txt1, txt2, r);

 

faf函数:

    public void faf(int t1, int t2, string rs)
    {
        string xixi=string.Empty;
        for (int j = t1; j >= 1; j--)
        {
            int t_1 = j - 1;
            int t_2 = t2 - j;
            if (t_2 == 0)
            {
                xixi += j + " " + rs + "<br>";
            }
            if ((1 + t_1) * t_1 > t_2 * 2)
            {
                string r_s = j + " " + rs;
                faf(t_1, t_2, r_s);
            }
        }
        a.Text = a.Text + xixi;
    }
我恨我没学好高等数学和离散数学 写不出好的算法-------哎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值