zoukankan      html  css  js  c++  java
  • 递归 打靶子问题

    原文发布时间为:2009-03-01 —— 来源于本人的百度文章 [由搬家工具导入]

    using System;
    //using System.Collections.Generic;
    //using System.Text;

    namespace digui1
    {
    public class Class2
        {
          public static int sum=0;
          public static int[] store=new int[10];

          public static void Main()
          {
              fun(90, 9);
              Console.WriteLine("总数为{0}", sum);
              Console.ReadLine();
          }

          public static void fun(int score, int num)
          {
              if (score < 0 || score > (num + 1) * 10)
                  return;
              if (num == 0)
              {
                  store[num] = score;
                  Output();
                  return;
              }
              for (int i = 0; i <= 10; i++)
              {
                  store[num] = i;
                  fun(score - i, num - 1);
              }
          }
          public static void Output()
          {
              for (int i = 9; i >= 0; i--)
              {
                  Console.Write("{0} ", store[i]);
              }
              Console.WriteLine();
              ++sum;
          }
        }
    }

  • 相关阅读:
    C# 泛型
    EventHandler<TEventArgs>委托
    只能输入数字 ,只能有一位小数点。
    MVC过滤器 AuthorizeAttribute使用
    NuGet EntityFramework 常用命令
    Stride游戏引擎试毒
    Unity EditorWindow GUI裁剪
    unity2017自定义编译dll
    Unity
    WPF
  • 原文地址:https://www.cnblogs.com/handboy/p/7148505.html
Copyright © 2011-2022 走看看