当前位置:网站首页>Experiment 4 QT
Experiment 4 QT
2022-06-30 08:02:00 【emplace_ back】
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_get_ans_clicked()
{
ui->m_ans->setText("");
if(ui->m_x->text().isEmpty()||ui->m_y->text().isEmpty()) return ;
bool ok=false;
int x=ui->m_x->text().toInt(&ok);
if(!ok) {
ui->m_x->setText("");
return ;
}
ok=false;
int y=ui->m_y->text().toInt(&ok);
if(!ok) {
ui->m_y->setText("");
return ;
}
QString op=ui->m_op->text();
if(op=="+") {
ui->m_ans->setText(QString::number(x+y));
} else if(op=="-") {
ui->m_ans->setText(QString::number(x-y));
} else if(op=="*") {
ui->m_ans->setText(QString::number(x*y));
} else if(op=="/") {
if(y==0) ui->m_ans->setText("diverror");
else ui->m_ans->setText(QString::number(x/y));
} else if(op=="^") {
int ans=1;
for(int i=0;i<y;i++) ans*=x;
ui->m_ans->setText(QString::number(ans));
} else if(op=="%") {
ui->m_ans->setText(QString::number(x%y));
} else {
ui->m_ans->setText("ERROR");
}
return ;
}
void MainWindow::on_exit_clicked()
{
close();
return ;
}
边栏推荐
- Deep learning -- feature point detection and target detection
- Simple application of generating function
- 想问问,炒股怎么选择证券公司?网上开户安全么?
- Deep learning -- sequence model and mathematical symbols
- Deep learning - LSTM
- The counting tool of combinatorial mathematics -- generating function
- 1163 Dijkstra Sequence
- C. Fishingprince Plays With Array
- C. Fishingprince Plays With Array
- November 22, 2021 [reading notes] - bioinformatics and functional genomics (Chapter 5, section 4, hidden Markov model)
猜你喜欢

CRM能为企业带来哪些管理提升

Permutation and combination of probability

Is it difficult to jump job ByteDance? With these skills, you can easily pass

Deep learning -- feature point detection and target detection
![November 9, 2020 [wgs/gwas] - whole genome analysis (association analysis) process (Part 2)](/img/21/ad74700921ee0ef7a1525dd7db0683.jpg)
November 9, 2020 [wgs/gwas] - whole genome analysis (association analysis) process (Part 2)

Redis 的过期数据如何处理,淘汰机制都有那些?

深度学习——特征点检测和目标检测

期末复习-PHP学习笔记5-PHP数组

Deep learning vocabulary representation

Self study notes -- use of 74h573
随机推荐
December 4, 2021 - Introduction to macro genome analysis process tools
深度学习——BRNN和DRNN
How CRM & PM helps enterprises create optimal sales performance
Deep learning -- sequence model and mathematical symbols
Program acceleration
为什么大学毕业了还不知道干什么?
深度学习——目标定位
Full stack performance testing theory - Summary
The counting tool of combinatorial mathematics -- generating function
TP5 set direct download file
Final review -php learning notes 1
What management improvements can CRM bring to enterprises
期末复习-PHP学习笔记5-PHP数组
[notes] polygon mesh processing learning notes (10)
1163 Dijkstra Sequence
Deep learning vocabulary representation
More, faster, better and cheaper. Here comes the fastdeploy beta of the low threshold AI deployment tool!
November 22, 2021 [reading notes] - bioinformatics and functional genomics (Section 5 of Chapter 5 uses a comparison tool similar to blast to quickly search genomic DNA)
Final review -php learning notes 2-php language foundation
November 9, 2020 [wgs/gwas] - whole genome analysis (association analysis) process (Part 2)