zoukankan      html  css  js  c++  java
  • hdu 1288 Hat's Tea

    这个要慢慢理解……

    #include<iostream>
    #include<stdio.h>
    #include<algorithm>
    #include<iomanip>
    #include<cmath>
    #include<string>
    using namespace std;
    int
    main()
    {

        int
    n,i,j,k,a1,a5,a10;
        bool
    flag;
        while
    (cin>>n>>a1>>a5>>a10&&(n+a1+a5+a10))
        {

            i=j=k=0;
            if
    (n%5>a1)
            {

                cout<<"Hat cannot buy tea."<<endl;
                continue
    ;
            }

            i=n%5;
            n-=i;
            a1-=i;
            if
    (n<=a1)
            {

                i+=n;
                printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                continue
    ;
            }

            a1/=5;
            n-=5*a1;
            i+=5*a1;
            if
    (n<=5*a5)
            {

                j+=n/5;
                printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                continue
    ;
            }

            n-=5*a5;
            j=a5;
            if
    (n%10==0)
            {

                if
    (n<=10*a10)
                {

                    k=n/10;
                    printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                    continue
    ;
                }

                else

                {

                    cout<<"Hat cannot buy tea."<<endl;
                    continue
    ;
                }
            }

            else

            {

                if
    (j>0)
                    j--;
                else

                {

                    if
    (i>=5)
                        i-=5;
                    else

                    {

                        cout<<"Hat cannot buy tea."<<endl;
                        continue
    ;
                    }
                }

                n+=5;
                if
    (n<=10*a10)
                {

                    k=n/10;
                    printf("%d YiJiao, %d WuJiao, and %d ShiJiao ",i,j,k);
                    continue
    ;
                }

                else

                {

                    cout<<"Hat cannot buy tea."<<endl;
                    continue
    ;
                }
            }
        }

        return
    0;
    }

  • 相关阅读:
    函数-列表生成式
    函数-闭包
    函数-参数
    函数-装饰器
    函数-函数递归
    函数-高阶函数
    函数-命名空间
    函数-匿名函数
    模块-shutil
    在 Android 5.1.1 执行 remount system failed 解决方法
  • 原文地址:https://www.cnblogs.com/xin-hua/p/3194479.html
Copyright © 2011-2022 走看看