Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mainwindow.h"
- #include "ui_mainwindow.h"
- #include "math.h"
- #include "string"
- #include "bits/stdc++.h"
- MainWindow::MainWindow(QWidget [id2956970|*parent]) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- }
- MainWindow::~MainWindow()
- {
- delete ui;
- }
- string transformation(int value, int base)
- {
- string output;
- while(value > 0)
- {
- char digit = value % base;
- if(digit < 10)
- digit += 48;
- else
- digit += 55;
- output += digit;
- int ost = value % base;
- value /= base;
- }
- reverse(output.begin(), output.end());
- return output;
- }
- void MainWindow::on_pushButton_Result_clicked()
- {
- QString str,bases;
- int input, base;
- str = ui->lineEdit_Decimal->text(); // input number
- bases = ui->lineEdit_Base->text(); // input base to
- input=str.toInt();
- base=bases.toInt();
- QString output;
- output = transformation(input, base);
- ui->label_Binary->setText(output); //output
- }
Add Comment
Please, Sign In to add comment