示例#1
0
void Sudoku::change(){
	srand(time(NULL));
	int a,b,n;
	
	a = rand()%9+1;
	b = rand()%9+1;
	while(a == b || b == 0){			
		b=rand()%9+1;
	}	
	changeNum(a,b);
	
	a = rand()%3;
	b = rand()%3;
	while(a == b){			
		b=rand()%3;
	}
	changeRow(a,b);
	
	a = rand()%3;
	b = rand()%3;
	while(a == b){			
		b=rand()%3;
	}
	changeCol(a,b);
	
	n = rand()%2;
	flip(n);
	
	n = rand()%101;
	rotate(n);
}
示例#2
0
void Sudoku::giveQuestion(){
    int array[81] = { 5, 3, 0, 0, 7, 0, 0, 0, 0,
                      6, 0, 0, 1, 9, 5, 0, 0, 0,
                      0, 9, 8, 0, 0, 0, 0, 6, 0,
                      8, 0, 0, 0, 6, 0, 0, 0, 3,
                      4, 0, 0, 8, 0, 3, 0, 0, 1,
                      7, 0, 0, 0, 2, 0, 0, 0, 6,
                      0, 6, 0, 0, 0, 0, 2, 8, 0,
                      0, 0, 0, 4, 1, 9, 0, 0, 5,
                      0, 0, 0, 0, 8, 0, 0, 7, 9 }; 

    Sudoku test(array);
    *this = test;
    srand(time(NULL));
    changeNum(rand() % 9 + 1, rand() % 9 + 1);
    changeRow(rand() % 3, rand() % 3);
    changeCol(rand() % 3, rand() % 3);
    rotate(rand() % 101);
    flip(rand() % 2);
    printSudokuSolution();

    /*for(int i = 0; i < 9; i++){
        for(int j = 0; j < 9; j++)
            cout<<array[i * 9 + j]<<" ";
        cout<<endl;
    }    */
}
示例#3
0
void Sudoku::change(){
    srand(time(NULL));
    changeNum(rand()%sudokuNum+1, rand()%sudokuNum+1);
    changeRow(rand()%3, rand()%3);
    changeCol(rand()%3, rand()%3);
    rotate(rand()%101);
    flip(rand()%2);
}
bool GuiGameListMenuCtrl::onKeyDown(const GuiEvent &event)
{
   switch (event.keyCode)
   {
      case KEY_UP:
         changeRow(-1);
         return true;

      case KEY_DOWN:
         changeRow(1);
         return true;

      case KEY_A:
      case KEY_RETURN:
      case KEY_NUMPADENTER:
      case KEY_SPACE:
      case XI_A:
      case XI_START:
         doScriptCommand(mCallbackOnA);
         return true;

      case KEY_B:
      case KEY_ESCAPE:
      case KEY_BACKSPACE:
      case KEY_DELETE:
      case XI_B:
      case XI_BACK:
         doScriptCommand(mCallbackOnB);
         return true;

      case KEY_X:
      case XI_X:
         doScriptCommand(mCallbackOnX);
         return true;

      case KEY_Y:
      case XI_Y:
         doScriptCommand(mCallbackOnY);
         return true;
      default:
         break;
   }

   return Parent::onKeyDown(event);
}
void GuiGameListMenuCtrl::onMouseDown(const GuiEvent &event)
{
   S32 hitRow = getRow(event.mousePoint);
   if (hitRow != NO_ROW)
   {
      S32 delta = (mSelected != NO_ROW) ? (hitRow - mSelected) : (mSelected + 1);
      changeRow(delta);
   }
}
示例#6
0
void Sudoku::change(){
	srand(time(NULL));
	for(int i=0; i<10; i++){
		changeNum(rand()%9+1, rand()%9+1);
		changeRow(rand()%3, rand()%3);
		changeCol(rand()%3, rand()%3);
		rotate(rand()%4);
		flip(rand()%2);
	}
}
示例#7
0
void Sudoku::transform(){
    srand(time(NULL));
    
    changeNum(rand() % 9 + 1, rand() % 9 + 1);
    changeRow(rand() % 3, rand() % 3);
    changeCol(rand() % 3, rand() % 3);
    rotate(rand() % 101);
    flip(rand() % 2);
    printSudokuSolution();    
}
示例#8
0
//! Updates the entire row
void PointTableWidget::updateTable(int row) {
        //Select the row representing the point
        if (settings.autoSelectRow && row != -1) {
            setCurrentCell(row, 1);
        }

        //Remove any unneeded rows
        while (points.size() < rowCount())
            removeRow(rowCount() - 1);

        for (int a = 0; a < points.size(); a++) {
            //Create and change rows as nessecary
            if (a >= rowCount())
                createNewRow(a);
            else
                changeRow(a);
        }
}
bool GuiGameListMenuCtrl::onGamepadAxisDown(const GuiEvent &event)
{
   changeRow(1);
   return true;
}
示例#10
0
void toResultDataSingle::changeSource(toResultModelEdit *model, int _row)
{
    delete Container;
    Container = new QScrollArea(this);
    layout()->addWidget(Container);

    Model = model;
    ProgressBar->setMaximum(Model->rowCount());
    ProgressBar->setValue(_row);

    QWidget *ext = new QWidget(Container);
    Container->setWidget(ext);
    Container->setWidgetResizable(true);

    QGridLayout *grid = new QGridLayout;
    ext->setLayout(grid);

    Value.clear();
    Null.clear();

    const toResultModel::HeaderList Headers = Model->headers();

    int row = 1 + Model->getPriKeys().size();
    int col = 0;

    for (; row < Headers.size(); row++, col = 0)
    {
        QLabel *name = new QLabel(Headers[row].name, this);
        grid->addWidget(name, row, col++);

        QLineEdit *edit = new QLineEdit(this);
        edit->setObjectName(QString::number(row));
        edit->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
                                        QSizePolicy::Minimum));
        grid->addWidget(edit, row, col);
        // edit widget should get the most space
        grid->setColumnStretch(col++, 1);

        QCheckBox *box = new QCheckBox(("NULL"), this);
        connect(box, SIGNAL(toggled(bool)), edit, SLOT(setDisabled(bool)));
        grid->addWidget(box, row, col++);

        toParamGetButton *btn = new toParamGetButton(row, this);
        btn->setText(tr("Edit"));
        btn->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed));
        connect(btn, SIGNAL(clicked(int)), this, SLOT(showMemo(int)));
        connect(box, SIGNAL(toggled(bool)), btn, SLOT(setDisabled(bool)));
        connect(box, SIGNAL(toggled(bool)), this, SLOT(saveRow()));
        connect(edit, SIGNAL(editingFinished()), this, SLOT(saveRow()));
        grid->addWidget(btn, row, col++);

        Value.append(edit);
        Null.append(box);
    }

    // add widget at bottom of grid so it can resize
    grid->addWidget(new QLabel(this), row, 0);
    grid->setRowStretch(row, 1);

    changeRow(Row);

    connect(Model,
            SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
            this,
            SLOT(dataChanged(const QModelIndex &, const QModelIndex &)));
}
示例#11
0
void toResultDataSingle::dataChanged(const QModelIndex &topLeft,
                                     const QModelIndex &bottomRight)
{
    if (topLeft.row() >= Row && bottomRight.row() <= Row)
        changeRow(Row);         // update
}