#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->spinBox,SIGNAL(valueChanged(int)),this,SLOT(changeMatrix(int))); connect(ui->pushButton,SIGNAL(clicked()),this,SLOT(count())); } MainWindow::~MainWindow() { delete ui; } void MainWindow::changeMatrix(int number) { ui->tableWidget->setColumnCount(number); ui->tableWidget->setRowCount(number); } void MainWindow::check() { std::cout<<"Checking..."<value<<": "; for (std::map::iterator it=result[i]->Map.begin(); it!=result[i]->Map.end(); ++it) { std::cout<first<<" "<second<<" "; } std::cout<value<<": "; for (std::map::iterator it=newel->Map.begin(); it!=newel->Map.end(); ++it) { std::cout<first<<" "<second<<" "; } std::cout<Map.size()Map.size()) { for (std::map::iterator it=result[i]->Map.begin(); it!=result[i]->Map.end(); ++it) { std::cout<<"Searching0: "<first<<" end: "<Map.end()->first<Map.find(it->first)==newel->Map.end()/*&&newel->Map.end()->first!=it->first*/) { std::cout<<"Not found0: "<value>=newel->value) { std::cout<<"Coinsidense => element should be deleated"<Map.size()>=newel->Map.size()) { for (std::map::iterator it=newel->Map.begin(); it!=newel->Map.end(); ++it) { std::cout<<"Searching1: "<first<<" end: "<Map.end()->first<Map.find(it->first)==result[i]->Map.end()/*&&result[i]->Map.end()->first!=it->first*/) { std::cout<<"Not found1: "<value<=newel->value) { std::cout<<"Coinsidense => element in vector should be deleated"<Map.size()==newel->Map.size()) { deleated = 1; break; } else { deleated = 0; } } } notfound = 0; } } if(!deleated||remove) { result.push_back(newel); std::cout<<"Adding new element"< > matrix) { for(unsigned int i=0; ivalue = matrix[i][0]; firstelem->Map[i] = 1; newel->value = min; newel->Map[i] = 1; // result.push_back(newel); iterator.push_back(firstelem); } for(unsigned int i=1; ivalue = std::min(iterator[j]->value,matrix[k][i]); for (std::map::iterator it=iterator[j]->Map.begin(); it!=iterator[j]->Map.end(); ++it) { //newel->Map = iterator[j]->Map; newel->Map[it->first] = 1; } newel->Map[k] = 1; this->check(); } } iterator = result; result.clear(); } } void MainWindow::count() { std::vector > matrix, matrix2, matrix3; std::vector newline; QTableWidgetItem *newItem; QString newdata; ui->textBrowser->clear(); double Mbuf = 0, min = 0; for(int i=0; itableWidget->columnCount(); i++) { for(int j=0; jtableWidget->columnCount(); j++) { newline.push_back(ui->tableWidget->item(i,j)->text().toDouble()); } matrix.push_back(newline); matrix2.push_back(newline); matrix3.push_back(newline); newline.clear(); } for(int i=0; iMbuf) Mbuf = min; } matrix3[k][i] = Mbuf; Mbuf = 0; } matrix2 = matrix3; } ui->tableWidget_2->setColumnCount(matrix3.size()); ui->tableWidget_2->setRowCount(matrix3.size()); for(unsigned int i=0; isetText(newdata); qDebug()<tableWidget_2->setItem(i,j,newItem); } this->minimize(matrix2); ui->textBrowser->append("Базы:"); this->showResult(); iterator.clear(); for(unsigned int i = 0; iminimize(matrix3); ui->textBrowser->append("Антибазы:"); this->showResult(); iterator.clear(); for(unsigned int i = 0; iminimize(matrix3); ui->textBrowser->append("Сильная связность:"); this->showResult(); iterator.clear(); // for(unsigned int i=0; ivalue = matrix2[i][0]; // firstelem->Map[i] = 1; // newel->value = min; // newel->Map[i] = 1; // // result.push_back(newel); // iterator.push_back(firstelem); // } // for(unsigned int i=1; ivalue = std::min(iterator[j]->value,matrix2[k][i]); // for (std::map::iterator it=iterator[j]->Map.begin(); it!=iterator[j]->Map.end(); ++it) // { // //newel->Map = iterator[j]->Map; // newel->Map[it->first] = 1; // } // newel->Map[k] = 1; // this->check(); // } // } // iterator = result; // result.clear(); // } // std::cout<<"Result vector:"<value<<": "; // resultbuf+=QString::number(iterator[i]->value)+"("; // for (std::map::iterator it=iterator[i]->Map.begin(); it!=iterator[i]->Map.end(); ++it) // { // std::cout<first<<" "<second<<" "; // resultbuf+="x"+QString::number(it->first); // } // resultbuf+=")v"; // std::cout<textBrowser->append(); // } // resultbuf.chop(1); // ui->textBrowser->append(resultbuf); } void MainWindow::showResult() { std::cout<<"Result vector:"<value<<": "; resultbuf+=QString::number(iterator[i]->value)+"("; for (std::map::iterator it=iterator[i]->Map.begin(); it!=iterator[i]->Map.end(); ++it) { std::cout<first<<" "<second<<" "; resultbuf+="x"+QString::number(it->first+1); } resultbuf+=")v"; std::cout<textBrowser->append(); } resultbuf.chop(1); ui->textBrowser->append(resultbuf); }