Advertisement
Jgug

Simplex_method_main

Apr 21st, 2014
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.91 KB | None | 0 0
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QDebug>
  4. #include <math.h>
  5.  
  6. MainWindow::MainWindow(QWidget *parent) :
  7.     QMainWindow(parent),
  8.     ui(new Ui::MainWindow)
  9. {
  10.     ui->setupUi(this);
  11. }
  12.  
  13. MainWindow::~MainWindow()
  14. {
  15.     delete ui;
  16. }
  17.  
  18. void MainWindow::on_pushButton_2_clicked()
  19. {
  20.     exit(0);
  21. }
  22.  
  23. void MainWindow::on_pushButton_clicked()
  24. {
  25.     int row = ui->lineEdit->text().toInt();
  26.     int column = ui->lineEdit_2->text().toInt();
  27.  
  28.  
  29.     //MAIN ELEMENT CALCULATION      work!
  30.     ui->tableWidgetResult->item(row,column)->setText(QString::number((
  31.                 pow((ui->tableWidget->item(row,column)->text().toDouble()),-1))));
  32.  
  33.  
  34.     //MAIN COLUMN CALCULATION       work!
  35.     int iN=0;
  36.     while (iN<6) {
  37.         if (iN!=row) {
  38.             ui->tableWidgetResult->item(iN,column)->setText(QString::number(
  39.                         pow(((ui->tableWidget->item(iN,column)->text().toDouble())*(-1)),-1)));
  40.         }
  41.         iN++;
  42.     }
  43.  
  44.  
  45.     //MAIN ROW CALCULATION      work!
  46.     int jN=0;
  47.     while (jN<5) {
  48.         if (jN!=column) {
  49.             ui->tableWidgetResult->item(row,jN)->setText(QString::number(
  50.                         pow((ui->tableWidget->item(column,jN)->text().toDouble()),-1)));
  51.         }
  52.         jN++;
  53.     }
  54.  
  55.  
  56.     //OTHER ELEMENTS        work!
  57.     int iM;
  58.     int jM;
  59.     for (iM=0; iM<6; iM++) {    //row
  60.         for (jM=0; jM<5; jM++) {    //columns
  61.             if (iM!=row && jM!=column) {
  62.                 ui->tableWidgetResult->item(iM,jM)->setText(QString::number(
  63.                             ( (ui->tableWidget->item(iM,jM)->text().toDouble()) -
  64.                               ((ui->tableWidget->item(iM,column)->text().toDouble()) *
  65.                               (ui->tableWidget->item(row,jM)->text().toDouble()) /
  66.                               (ui->tableWidget->item(row,column)->text().toDouble())) ) ) );
  67.             }
  68.         }
  69.     }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement