akela43

Untitled

Aug 26th, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. using namespace std;
  5. int main() {
  6.     double a, b, c, d, e , f;
  7.     cin >> a >> b >> c >> d >> e >> f;
  8.     double D; // определитель
  9.     double Dy; // определитель Dy
  10.     double Dx; // определитель Dx
  11.     double x, y;
  12.    
  13.  
  14.     D = a * d - b * c;
  15.     if (D != 0) { // единственное решение
  16.         // решаем методом Крамера
  17.         Dx = e * d - b * f;
  18.         Dy = a * f - c * e;
  19.         x = Dx / D;
  20.         y = Dy / D;
  21.         cout << 2 << x << " " << y;
  22.     }
  23.     else
  24.     {
  25.         if (((a == 0) && (b == 0) && (e != 0))  ||
  26.                ((c == 0) && (d == 0) && (f != 0)) )
  27.         {
  28.             // несовместна
  29.             cout  << 0;
  30.         }
  31.         else
  32.         {
  33.             if (((a == 0) && (b == 0) && (e == 0))  ||
  34.                    ((c == 0) && (d == 0) && (f == 0)) )
  35.             {
  36.                 // любая пара x0 y0
  37.                 cout  << 5;
  38.             }
  39.            
  40.         }
  41.         else
  42.         {
  43.            
  44.         }
  45.  
  46.     }
  47.  
  48.  
  49.  
  50.     return 0;
  51. }
  52.  
  53. void MainWindow::on_pushButton_clicked()
  54. {
  55.     QString strValue = ui->m_pQLineEdit->text();
  56.     QString result = crypto.encryptToString(strValue);
  57.     QByteArray pswNsalt (strValue.toStdString().c_str()) ;
  58.     pswNsalt.append(ui->lineEdit_salt_key->text()) ;
  59.     QString hashedSaltedPsw = QCryptographicHash::hash(pswNsalt, QCryptographicHash::Sha256).toHex() ;
  60.     qDebug() << "encrypted psw: " << result << "\n" ;
  61.     ui->lineEdit_hash->setText(result);
  62. }
  63.  
  64. void MainWindow::on_pushButton_decrypt_clicked()
  65. {
  66.     QByteArray pswNsalt (ui->lineEdit_hash->text().toStdString().c_str()) ;
  67.     pswNsalt.append(ui->lineEdit_salt_key->text()) ;
  68.     QString hashedSaltedPsw = QCryptographicHash::hash(pswNsalt, QCryptographicHash::Sha256).toHex() ;
  69.  
  70.     QString decrypted = crypto.decryptToString(ui->lineEdit_hash->text());
  71.     qDebug() << "encrypted psw: " << decrypted << endl ;
  72.     ui->lineEdit_decrypt->setText(decrypted);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment