zoukankan      html  css  js  c++  java
  • 计算正整数被标示为连续正整数的和

    找出某个正整数可能被表示成n个连续的正整数之和.

    如 11 = 5+6

    代码
     1 private void Calc(int iValue)
     2     {
     3         int tValue = iValue;
     4         int MidValue = iValue / 2 + 1;
     5         for (int i = 1; i < MidValue; i++)
     6         {
     7             fun(i, i, iValue);
     8         }
     9     }
    10 
    11     private void fun(int start, int end, int cValue)
    12     {
    13         if (cValue > end)
    14         {
    15             fun(start, end + 1, cValue - end);
    16         }
    17         else if(cValue == end) //输出
    18 
    19         {
    20             for (int j = start; j < cValue + 1; j++)
    21             {
    22                 Response.Write(j.ToString()+"==");
    23             }
    24         }
    25     }
    26 
    27 
  • 相关阅读:
    token
    id
    vim
    http_proxy
    brew
    认证
    go
    linux 磁盘管理
    vmware
    vmware fusion
  • 原文地址:https://www.cnblogs.com/benwu/p/1735674.html
Copyright © 2011-2022 走看看