zoukankan      html  css  js  c++  java
  • 软件工程概论 购书最低价格问题

    思路:只有8这个数特殊,3+5>4+4,其他的只要除5取余即可。

    我偷了个懒,直接罗列if...

    #include <iostream>
    using namespace std;
    
    void main()
    {
        int n;
        int i;
        cout<<"请输入本数:"<<endl; 
        cin>>n;
    
        i = n/5;
    
        if(n<5)
        {
            if(n==1)  cout<<"最低价格为8元"<<endl;
            if(n==2)  cout<<"最低价格为"<<n*8*0.95<< ""<<endl;
            if(n==3)  cout<<"最低价格为"<<n*8*0.9<< ""<<endl;
            if(n==4)  cout<<"最低价格为"<<n*8*0.8<< ""<<endl;
        }
        else
        {
            if(n%5==0)
            {
                cout<<i<<"套5本的"<<endl;
                cout<<"最低价格为:"<<i*8*5*0.75<< endl;
            }
            if(n%5==1)
            {
                cout<<i<<"套5本"<<endl;
                cout<<""<<n%5<<""<<endl;
                cout<<"最低价格为:"<<i*8*5*0.75+(n%5)*8<<endl;
            }
            if(n%5==2)
            {
                cout<<i<<"套5本"<<endl;
                cout<<""<<n%5<<""<<endl;
                cout<<"最低价格为:"<<i*8*5*0.75+(n%5)*8*0.95<<endl;
            }
            if(n%5==3)
            {
                cout<<i-1<<"套5本的"<<endl;
                cout<<"加2套4本"<<endl;
                cout<<"最低价格为:"<<(i-1)*8*5*0.75+2*4*8*0.8<<endl;
            }
            if(n%5==4)
            {
                cout<<i<<"套5本"<<endl;
                cout<<""<<n%5<<""<<endl;
                cout<<"最低价格为:"<<i*8*5*0.75 +(n%5)*8*0.8<<endl;
            }
        }
    }

  • 相关阅读:
    adoQuery对象池
    面向對象囈語
    TDataSetProvider 元件的設定
    Midas的三種調用遠程方法的方式
    線程池
    数据库连接池类
    remobject 簡介
    多層開發注重效率的注意點
    修改的一个导出DataSet到xls的单元
    Git 换行符检查 CRLF 与 LF
  • 原文地址:https://www.cnblogs.com/apak/p/4495287.html
Copyright © 2011-2022 走看看