一块钱一瓶水  两个瓶子可以换一瓶水  给你100块钱 可以喝多少瓶水
用C# 实现

解决方案 »

  1.   

    int result = 100 * 2 - 1;
      

  2.   


    int nPingZiCount=100;//每次瓶子的数目,最开始是100int nResult=0;//可以喝的水数目do
    {
       nResult+=nPingZiCount;
       nPingZiCount=nPingZiCount/2;
    }
    while(nPingZiCount>0);//结果在nResult中,
      

  3.   

    确切地说是
    int n = 100 / 1;
    int result = n * 2 - 1;
      

  4.   

    <script type="text/javascript">
            var howMuchBottle = 0;
            function count(totalMoney) {
                var i = 1;
                while (i < totalMoney && i != totalMoney) {
                    howMuchBottle += Math.floor(totalMoney / i);
                    i *= 2;
                }
                return howMuchBottle++;
            }        alert(count(20));
        </script>
      

  5.   

     int i = 100; //瓶子数
     int sum = 0; //喝到多少瓶水
     sum = i;
     while (i > 1)
     {
         sum += i / 2;
         i = i % 2 + i / 2;
     }              
      

  6.   

    int nCount = money;
                int nResult = 0;
                nResult += nCount;            while (nCount > 1)
                {
                    nCount -= 2;
                    nResult++;
                    nCount += 1;
                }
                Console.WriteLine(nResult);
      

  7.   

    int nCount = money;
                int nResult = 0;
                nResult += nCount;            while (nCount > 1)
                {
                    nCount -= 2;
                    nResult++;
                    nCount += 1;
                }
                Console.WriteLine(nResult);
      

  8.   

    想要什么样的解法啊。很多种的。程序算法:int kp=100;
     int he=100;
     int nhe=0;
     do
     {
    nhe=kp/2;
    he+=nhe;
    kp=kp/2+kp%2;
     }
     while(kp>=2);
     printf("%d\n",he);
      

  9.   

    Lz结贴是正道!楼上都答完了,LZ你还想得到什么样的答案你补充啊!