コード例 #1
0
void Solve3()
{
    int width, height;
    for(int i=0;i<4;i++)
    {
        for(int j=0;j<4;j++)
        {
            if(i==j) continue;
            int temp1=0, temp2=0;
            int temp3=0, temp4=0;
            Rect temp[4];
            int t=0;
            for(int k=0;k<4;k++)
            {
                if(k!=i and k!=j)
                {
                    temp1+=rect[k].width;
                    temp2=max(temp2,rect[k].height);
                    temp3+=rect[k].height;
                    temp4=max(temp4,rect[k].width);
                    temp[t].width=rect[k].width,temp[t++].height=rect[k].height;
                }
            }
            width=max(temp1,rect[j].height)+rect[i].width;
            height=max(temp2+rect[j].width, rect[i].height);
            addAnswer(width,height);
            width=rect[i].width+rect[j].width+temp4;
            height=max(max(rect[i].height,rect[j].height),temp3);
            addAnswer(width,height);
            width=rect[i].width+rect[j].width;
            if(temp1<=width)
            {
                if(temp[0].height<temp[1].height)
                {
                    swap(temp[0].width,temp[1].width);
                    swap(temp[0].height,temp[1].height);
                }
                temp[2].width=rect[i].width, temp[2].height=rect[i].height;
                temp[3].width=rect[j].width, temp[3].height=rect[j].height;
                if(temp[2].height>temp[3].height)
                {
                    swap(temp[2].width,temp[3].width);
                    swap(temp[2].height,temp[3].height);
                }
                if(temp[0].width<=temp[2].width)
                {
                    height=max(temp[0].height+temp[2].height,temp[1].height+temp[3].height);
                    addAnswer(width,height);
                }
            }
        }
    }
}
コード例 #2
0
ファイル: matching.cpp プロジェクト: amireh/libcanvas
  void Matching::deserialize(JSONValue &document) {
    QuizQuestion::deserialize(document);

    if (document["answers"].isArray()) {
      for (auto answerDocument : document["answers"]) {
        addAnswer(answerDocument);
      }
    }

    if (document["matches"].isArray()) {
      for (auto mDocument : document["matches"]) {
        Match match;
        match.text = mDocument["text"].asString();
        match.id = mDocument["match_id"].asUInt();

        mMatches.push_back(match);
      }
    }
    if (document["matching_answer_incorrect_matches"].isString()) {
      String distractors = document["matching_answer_incorrect_matches"].asString();

      for (auto distractor : Utility::split(distractors, '\n')) {
        Match match;
        match.text = distractor;
        match.id = 0;

        mDistractors.push_back(match);
      }
    }
  }
コード例 #3
0
ファイル: QueryInterface.cpp プロジェクト: Yarrick13/hwasp
Clause*
QueryInterface::computeClauseFromCandidates()
{
    Clause* clause = new Clause();
    unsigned int j = 0;
    for( unsigned int i = 0; i < candidates.size(); i++ )
    {
        Var v = candidates[ j ] = candidates[ i ];
        assert( !solver.isUndefined( v ) );
        if( !solver.isTrue( v ) )
            continue;
        
        if( solver.getDecisionLevel( v ) == 0 )
            addAnswer( v );
        else
        {
            clause->addLiteral( Literal( v, NEGATIVE ) );
            j++;
        }
    }    
    candidates.shrink( j );
    clause->setCanBeDeleted( false );
    printCandidates();
    return clause;
}
コード例 #4
0
ファイル: calculated.cpp プロジェクト: amireh/libcanvas
  void Calculated::deserialize(JSONValue &document) {
    QuizQuestion::deserialize(document);

    if (document["answers"].isArray()) {
      for (auto answerDocument : document["answers"]) {
        ID answerId = answerDocument["id"].asUInt();

        addAnswer(answerId, [&answerDocument](CalculatedAnswer *answer) {
          answer->deserialize(answerDocument);
        });
      }
    }

    if (document["variables"].isArray()) {
      for (auto vDocument : document["variables"]) {
        Variable variable;
        variable.name = vDocument["name"].asString();
        variable.min = vDocument["min"].asDouble();
        variable.max = vDocument["max"].asDouble();
        variable.precision = vDocument["scale"].asInt();

        mVariables.push_back(variable);
      }
    }
  }
コード例 #5
0
ファイル: DnsLayer.cpp プロジェクト: kingjason/PcapPlusPlus
DnsResource* DnsLayer::addAnswer(DnsResource* const copyAnswer)
{
	if (copyAnswer == NULL)
		return NULL;

	return addAnswer(copyAnswer->getName(), copyAnswer->getDnsType(), copyAnswer->getDnsClass(), copyAnswer->getTTL(), copyAnswer->getDataAsString());
}
コード例 #6
0
void Solve1()
{
    int width=0,height=0;
    for(int i=0;i<4;i++)
    {
        width+=rect[i].width;
        height=max(height,rect[i].height);
    }
    addAnswer(width,height);
}
コード例 #7
0
ファイル: answersedit.cpp プロジェクト: flcl42/itest
AnswersEdit::AnswersEdit(QWidget * parent):
QWidget(parent) {
    QVBoxLayout * vlayout = new QVBoxLayout(this);
    vlayout->setContentsMargins(0, 0, 0, 0);
#ifndef Q_WS_MAC
    vlayout->setSpacing(6);
#else
    vlayout->setSpacing(3);
#endif
    QHBoxLayout * hlayout = new QHBoxLayout;
    hlayout->setContentsMargins(0, 0, 0, 0); hlayout->setSpacing(6);
    ae_add_button = new QToolButton(this);
    ae_add_button->setText(tr("Add answer"));
    ae_add_button->setIcon(QIcon(QString::fromUtf8(":/images/images/list-add.png")));
    QObject::connect(ae_add_button, SIGNAL(released()), this, SLOT(addAnswer()));
    hlayout->addWidget(ae_add_button);
    hlayout->addStretch();
    ae_answers_label = new QLabel(tr("Answers:"), this);
    hlayout->addWidget(ae_answers_label);
    hlayout->addStretch();
    ae_singleselection = new QRadioButton(tr("Single choice"), this);
    ae_singleselection->setStatusTip(tr("Single choice questions allow selecting one answer only, even if the question has more correct answers"));
    ae_singleselection->setChecked(true);
    hlayout->addWidget(ae_singleselection);
#ifdef Q_WS_MAC
#if QT_VERSION < 0x040400
    hlayout->addSpacing(6);
#endif
#endif
    ae_multiselection = new QRadioButton(tr("Multiple choice"), this);
    ae_multiselection->setStatusTip(tr("Multiple choice questions allow selecting more answers"));
    hlayout->addWidget(ae_multiselection);
    hlayout->addStretch();
    ae_correct_label = new QLabel(tr("Correct:"), this);
    hlayout->addWidget(ae_correct_label);
    vlayout->addLayout(hlayout);
#ifdef Q_WS_MAC
    QVBoxLayout * vlayout2 = new QVBoxLayout;
    vlayout2->setContentsMargins(0, 0, 0, 0); vlayout2->setSpacing(0);
    vlayout->addLayout(vlayout2);
#endif
    for (int i = 0; i < 9; ++i) {
        AnswerEdit * ans = new AnswerEdit(i, this);
        if (i >= 4) { ans->setVisible(false); }
        ae_answers << ans;
#ifndef Q_WS_MAC
        vlayout->addWidget(ans);
#else
        vlayout2->addWidget(ans);
#endif
    }
    ae_add_button->setMaximumSize(16777215, ae_answers.at(0)->ans_text->sizeHint().height());
    ae_add_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
}
コード例 #8
0
ファイル: QueryInterface.cpp プロジェクト: Yarrick13/hwasp
void
QueryInterface::iterativeCoherenceTesting()
{
    solver.unrollToZero();
    assert( solver.getCurrentDecisionLevel() == 0 );
    assert( !solver.conflictDetected() );
    
    vector< Literal > assumptions;    
    while( !candidates.empty() )
    {
        Var v = candidates.back();
        if( !solver.isUndefined( v ) )
        {
            assert( solver.getDecisionLevel( v ) == 0 );
            if( solver.isTrue( v ) )
                addAnswer( v );
            
            candidates.pop_back();            
            continue;
        }
        
        assert( solver.isUndefined( v ) );
        assumptions.push_back( Literal( v, NEGATIVE ) );
        unsigned int result = solver.solve( assumptions );
        
        if( result == COHERENT )
            reduceCandidates();
        else
        {
            assert( result == INCOHERENT );        
            addAnswer( v );
            candidates.pop_back();
        }
        
        solver.unrollToZero();
        assert( solver.getCurrentDecisionLevel() == 0 );
        assert( !solver.conflictDetected() );        
        assumptions.clear();
    }        
}
コード例 #9
0
void SettingsWidget::loadImpl()
{
	Config config("control");
	config.beginGroup("general");
	ui->usernameEdit->setText(config.value("username", QString()));
	ui->passwordEdit->setText(config.value("password", QString(), Config::Crypted));
	ui->urlEdit->setText(config.value("url", QString()));
	ui->requestUrlEdit->setText(config.value("requestUrl", QString()));
	ui->answersList->clear();
	const QStringList answers = config.value("answers", QStringList());
	foreach (const QString &text, answers)
		addAnswer(text);
}
コード例 #10
0
ファイル: multiple_choice.cpp プロジェクト: amireh/libcanvas
  void MultipleChoice::deserialize(JSONValue &document) {
    QuizQuestion::deserialize(document);

    if (document["answers"].isArray()) {
      for (auto answerDocument : document["answers"]) {
        ID answerId = answerDocument["id"].asUInt();

        addAnswer(answerId, [&answerDocument](QuizQuestionAnswer *answer) {
          answer->deserialize(answerDocument);
        });
      }
    }
  }
コード例 #11
0
ファイル: QueryInterface.cpp プロジェクト: Yarrick13/hwasp
void
QueryInterface::reduceCandidates()
{
    unsigned int j = 0;
    for( unsigned int i = 0; i < candidates.size(); i++ )
    {
        Var v = candidates[ j ] = candidates[ i ];
        assert( !solver.isUndefined( v ) );
        if( !solver.isTrue( v ) )
            continue;
        
        if( solver.getDecisionLevel( v ) == 0 )
            addAnswer( v );
        else
            j++;
    }    
    candidates.shrink( j );
    printCandidates();
}
コード例 #12
0
ファイル: QueryInterface.cpp プロジェクト: Yarrick13/hwasp
void
QueryInterface::computeCandidates()
{
    for( unsigned int i = 1; i <= solver.numberOfVariables(); i++ )
    {
        Var v = i;
        if( VariableNames::isHidden( v ) )
            continue;

        assert_msg( !solver.hasBeenEliminated( v ), "Variable " << Literal( v, POSITIVE ) << " has been deleted" );
        if( !solver.isTrue( v ) )
            continue;
        
        if( solver.getDecisionLevel( v ) == 0 )
            addAnswer( v );
        else
            candidates.push_back( v );
    }
}
コード例 #13
0
void Solve2()
{
    int width,height;
    for(int i=0;i<4;i++)
    {
        int temp1=0,temp2=0;
        for(int j=0;j<4;j++)
        {
            if(i!=j)
            {
                temp1+=rect[j].width;
                temp2=max(temp2,rect[j].height);
            }
        }
        width=max(temp1,rect[i].height);
        height=temp2+rect[i].width;
        addAnswer(width,height);
    }
}
コード例 #14
0
ファイル: robot.cpp プロジェクト: Iownnoname/qt
void Robot::handleTrainSchedule_step1(const QString& list)
{
    int pos = 1;
    QString train;//将list里的每一躺火车信息分割到train里
    for(; pos < list.size(); pos++)
    {
        if(list.at(pos) == QChar('}'))
        {
            QString icon,detailurl;
            QString text = handleTrainSchedule_step2(train,icon,detailurl);

            QNetworkReply* r = network->get(icon);

            Info info;
            info.setDialog(addAnswer(text));
            _replys[r] = info;
            train = "";
            continue;
        }

        train += list.at(pos);
    }
}
コード例 #15
0
ファイル: QueryInterface.cpp プロジェクト: Yarrick13/hwasp
void
QueryInterface::overestimateReduction()
{        
    solver.turnOffSimplifications();
    Clause* clausePointer = computeClauseFromCandidates();
    unsigned int size = clausePointer->size();    
    solver.unrollToZero();
    assert( solver.getCurrentDecisionLevel() == 0 );
    assert( !solver.conflictDetected() );
    if( !solver.addClauseRuntime( clausePointer ) )
        return;

    while( solver.solve() == COHERENT )
    {
        if( size > 2 )
        {
            assert( clausePointer->size() > 2 );
            solver.detachClause( *clausePointer );
        }

        clausePointer = computeClauseFromCandidates();
        size = clausePointer->size();
        solver.unrollToZero();
        assert( solver.getCurrentDecisionLevel() == 0 );
        assert( !solver.conflictDetected() );

        if( !solver.addClauseRuntime( clausePointer ) )
            return;
    }
    
    for( unsigned int i = 0; i < candidates.size(); i++ )
    {
        Var v = candidates[ i ];
        assert( solver.isTrue( v ) && solver.getDecisionLevel( v ) == 0 );
        addAnswer( v );
    }
}
コード例 #16
0
void SettingsWidget::on_addButton_clicked()
{
	addAnswer();
	setModified(true);
}
コード例 #17
0
ファイル: settingswidget.cpp プロジェクト: rnz/qutim
void SettingsWidget::on_addButton_clicked()
{
	addAnswer();
	emit modifiedChanged(true);
}
コード例 #18
0
ファイル: robot.cpp プロジェクト: Iownnoname/qt
void Robot::handleDownload(QNetworkReply* reply)
{
    Info info = _replys[reply];

    if(info.isText())
    {
        QString what;

        QString codestr;

        what = QString::fromUtf8(reply->readAll());
        int pos = what.indexOf(answer_code);

        for(int i = pos + 6; ; i++)
        {
            if(what.at(i) == QChar(','))
            {
                break;
            }

            if(what.at(i) == QChar('}'))
            {
                break;
            }

            if(what.at(i) == QChar('"'))
            {
                break;
            }

            if(i >= what.size())
            {
                break;
            }
            codestr += what.at(i);
        }

        if(codestr == "100000")
        {
            QString &answer = handleText(what);
            addAnswer(answer);
        }
        else if(codestr == "305000")
        {
            QString &answer = handleText(what);
            addAnswer(answer);
            handleTrainSchedule(what);
        }
    }
    else
    {
        //这个时候下截来的图片,肯定是属于某一个对话的
        Dialog* d = info.getDialog();

        QPixmap pix;
        pix.loadFromData(reply->readAll());
        d->setPix(pix);
    }

    _replys.erase(reply);
    reply->deleteLater();
}