将简单的C ++代码转换为Google文档电子表格或Excel

时间:2014-04-08 10:26:22

标签: c++ excel google-docs

我需要将简单的C ++代码转换为Google文档电子表格,但不幸的是,由于括号问题,它无法正常工作......请您帮我修复Google doc格式?

C ++代码

#ifndef DEMMURAGE_H
#define DEMMURAGE_H

#include <QtCore>

class Demmurage : public QObject
{
    Q_OBJECT
public:
    Demmurage(QDate vesselArrival,
              QDate containerDelivery,
              int containerSize,
              int freeDuration = 10,
              int stageOneDays = 10,
              int stageOne40Dem = 15,
              int stageTwo40Dem = 25,
              int stageOne20Dem = 10,
              int stageTwo20Dem = 15,
              double dollarToDynar = 1.4)
    {
        _arrival = vesselArrival;
        _delivery = containerDelivery;
        _containerSize = containerSize;
        _freeDuration = freeDuration;
        _stageOneDays = stageOneDays;
        _stageOne40Dem = stageOne40Dem;
        _stageTwo40Dem = stageTwo40Dem;
        _stageOne20Dem = stageOne20Dem;
        _stageTwo20Dem = stageTwo20Dem;
        _dollarToDynar = dollarToDynar;

        _demurrage = 0;
        int duration = _arrival.daysTo(_delivery) - _freeDuration;
        if (duration > 0) {
            if (duration - _stageOneDays <= 0) {
                if (containerSize == 40)
                    _demurrage = duration * _stageOne40Dem * _dollarToDynar;
                else
                    _demurrage = duration * _stageOne20Dem * _dollarToDynar;
            } else {
                if (containerSize == 40)
                    _demurrage = (_stageOneDays * _stageOne40Dem * _dollarToDynar) + ( (duration - _stageOneDays) * _stageTwo40Dem * _dollarToDynar);
                else
                    _demurrage = (_stageOneDays * _stageOne20Dem * _dollarToDynar) + ( (duration - _stageOneDays) * _stageTwo20Dem * _dollarToDynar);
            }
        }
    }
    double demmurage()
    {
        return _demurrage;
    }

    virtual ~Demmurage() {}
private:
    double _demurrage;
    int _freeDuration;
    int _stageOneDays;
    int _stageOne40Dem;
    int _stageTwo40Dem;
    int _stageOne20Dem;
    int _stageTwo20Dem;
    double _dollarToDynar;
};

#endif // DEMMURAGE_H

Google docs电子表格的单元格:

=if( ((L84-I84-10) > 0), ((if ((L84-I84-10) - 10 <= 0), (if( (F84==40), (L84-I84-10)*15*1.4, (L84-I84-10)*10*1.4 )), (if( (F84==40), (10*15*1.4)+(((L84-I84-10)-10)*25*1.4), (10*10*1.4)+(((L84-I84-10)-10)*15*1.4) )))), 0)

1 个答案:

答案 0 :(得分:0)

我发现了错误......因为(IF40==

而发生错误

正确的格式是:

=if((L84-I84-10)>0,if((L84-I84-10)-10<=0,if(F84=40,(L84-I84-10)*15*1.4,(L84-I84-10)*10*1.4),if(F84=40,(10*15*1.4)+(((L84-I84-10)-10)*25*1.4),(10*10*1.4)+(((L84-I84-10)-10)*15*1.4))),0)