李白无事街上走,提壶去买酒。遇店加一倍,见花喝一斗,五遇花和店,喝光壶中酒,试问李白壶中原有多少斗酒?(使用for循环结构实现)
题目好像我有点读不懂来着··

解决方案 »

  1.   

    1。设原有酒X升。1斗=10升。 
    2。一遇店:X*2=2X。 
    3。一遇花:2X-10。 
    4。二遇店:(2X-10)*2。 
    5。二遇花:4X-20-10。 
    6。三遇店:(4X-30)*2-10。 
    7。三遇花:8X-60-10=0 
    8。解方程:8X=70,X=8。75升。李白壶中原有 
    8。75升酒。 
    壶中原有7/8斗酒. 
      

  2.   

    LZ是 彭某某 ?
    主要是因为昨天他才问了我这个问题我用C#写的代码,可以显示出可能出现的情况(花和店的各种组合)
    算出最终结果需要在下面的代码中加些东西但下面这个方法效率很低,需要半分钟至于2楼的朋友给出的答案,只是花和店出现顺序的一种[code=C#]
    using System;
    using System.Collections.Generic;
    using System.Text;namespace Sort
    {
        public class Sort
        {
            private List<String> result = new List<String>();        private char[] chang(char[] str, int m)
            {
                int i = 0;
                char temp = str[0];
                for (i = 0; i < m - 1; i++)
                {
                    str[i] = str[i + 1];
                }
                str[i] = temp;
                return str;
            }        private void pai(char[] str, int m, int n) /* 定义全排列函数 */
            {
                int k;
                str = chang(str, m);
                if (m < n) /* 定 义 递 归 调 用 出 口 */
                {
                    for (k = 0; k <= m; k++)
                    {
                        pai(str, m + 1, n); /* 递归调用 */
                        chang(str, m); /* 调用左移函数 */
                    }
                }
                else
                {
                    String tempResult = "";
                    for (int i = 0; i < str.Length; i++)
                    {
                        tempResult += str[i];
                    }
                    result.Add(tempResult);
                }
            }        // 这是得到全排列的方法
            public List<string> showResult(String numbers)
            {
                char[] str = numbers.ToCharArray();
                pai(str, 0, str.Length);
                return result;
            }
        }    class Program
        {
            static void Main(string[] args)
            {
                Test("01");// 2种情况
                Test("0011");// 6
                Test("000111");// 20
                Test("00001111");// 70
                Test("0000011111");// 252
            }        private static void Test(string str)
            {
                List<string> list = new Sort().showResult(str);// 全排列
                List<string> list2 = new List<string>();// 最终结果            foreach (string var in list)
                {
                    if (!list2.Contains(var))
                    {
                        list2.Add(var);
                    }
                }
                Console.WriteLine("\n" + list2.Count);
            }
        }
    }
    [/code]
      

  3.   

    package execise;public class Libai { /**
     * @param args
     */
    public static void main(String[] args) {
    // TODO Auto-generated method stub libai();
    } public static void libai(){
    int wine;
    int y;
    int res;
    for(wine=0;wine<10000;wine++){
    for(int x=0;x<5;x++){
    y=5-x;
    res=x*(2*wine)-y*(wine-10);
    if(res==0){
    System.out.println(wine);
    }
    }}


    }
    }
    写了一个,LZ看看答案对不?
      

  4.   

    ===蜗牛小屋,编程开发,Java,j2se,j2me,j2ee,新手入门,高级技术,核心技术,资料,技术文章,个人收藏,开发笔记,网络编程 http://www.pjwqh.cn ===
      

  5.   

    倒着推,先遇到花,遇花加一斗,遇店喝一半
    for(int i = 0 ; i < 10 ; i++){
    if(i%2 == 0){}
    else{}
    }
      

  6.   


    我不是彭某某,我是新手才来没几天呢。这个题目主要是让我用for循环来做, 应该暂时不考虑花和店的顺序问题吧· C#我还没学呢·
      

  7.   

    code=Java]
    public class Practise {    /**
         * @param args
         */
        public static void main(String[] args) {
            BigDecimal x = new BigDecimal(0);
            for (int i = 0; i < 5; i++) {
                x = x.add(new BigDecimal(1));
                x = x.divide(new BigDecimal(2));
            }
            System.out.println(x);
        }
    }[/code]
      

  8.   

    9#正解吧
    import java.math.*;public class Libai {
    public static void main(String args[]){
    BigDecimal volumn = new BigDecimal("0");

    for (int i=0; i<5;  i++){
    volumn = volumn.add(new BigDecimal("1"));
    volumn = volumn.divide(new BigDecimal("2"));
    }

    System.out.print(volumn);
    }
    }0.96875
      

  9.   

    public static void libai(){ 
    int wine; 
    int y; 
    int res; 
    for(wine=0;wine <10000;wine++){ 
    for(int x=0;x <5;x++){ 
    y=5-x; 
    res=x*(2*wine)-y*(wine-10); 
    if(res==0){ 
    System.out.println(wine); 
      

  10.   

    import java.math.*;public class libai { public static void main(String[] args) {
     BigDecimal x = new BigDecimal(0); 
            for (int i = 0; i < 5; i++) { 
                x = x.add(new BigDecimal(1)); 
                x = x.divide(new BigDecimal(2)); 
            } 
            System.out.println(x); 
        }  }
      

  11.   

    public static void main(String[] args) {
    // TODO Auto-generated method stub
    double s=1d,sum;
    for(int i=1;i<=5;i++){
    s=s/2+1;
    }
    sum=s-1;
    System.out.println("原来有:"+sum+"斗酒");
    }