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

  • 相关阅读:
    Use "Attach to Process" in VC Express 2010
    韩国三日游
    可耻的没通过Autodesk 3ds Max初级认证
    Trace depth and rays per second per core
    References on SSS
    Free Shave SDK
    New wisdom on offline/interactive rendering
    匹配汉字的正则表达式
    WPF中richtextbox的一些用法
    C#中禁止一个程序打开多次
  • 原文地址:https://www.cnblogs.com/handboy/p/7148505.html
Copyright © 2011-2022 走看看