feat(软件设计): 考试
This commit is contained in:
parent
112ea9535e
commit
be4e36e240
6 changed files with 290 additions and 0 deletions
24
SoftwareDesign/Lab6/2020114490/2020114490.pro
Normal file
24
SoftwareDesign/Lab6/2020114490/2020114490.pro
Normal file
|
@ -0,0 +1,24 @@
|
|||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
!isEmpty(target.path): INSTALLS += target
|
11
SoftwareDesign/Lab6/2020114490/main.cpp
Normal file
11
SoftwareDesign/Lab6/2020114490/main.cpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
36
SoftwareDesign/Lab6/2020114490/mainwindow.cpp
Normal file
36
SoftwareDesign/Lab6/2020114490/mainwindow.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
//设置TAB顺序
|
||||
setTabOrder(ui->equal, ui->x0);
|
||||
setTabOrder(ui->x0, ui->x1);
|
||||
setTabOrder(ui->x1, ui->w0);
|
||||
setTabOrder(ui->w0, ui->w1);
|
||||
setTabOrder(ui->w1, ui->b);
|
||||
setTabOrder(ui->b, ui->equal);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() { delete ui; }
|
||||
|
||||
void MainWindow::on_equal_clicked() {
|
||||
double num = ui->x0->value() * ui->w0->value() +
|
||||
ui->x1->value() * ui->w1->value() + ui->b->value();
|
||||
|
||||
qDebug() << num;
|
||||
|
||||
num = sigmoid(num);
|
||||
|
||||
ui->result->setText(QString::number(num, 'f', 16));
|
||||
ui->list->addItem("f(" + QString::number(ui->x0->value(), 'f', 2) + "," +
|
||||
QString::number(ui->x1->value(), 'f', 2) +
|
||||
")=" + QString::number(num, 'f', 2));
|
||||
}
|
||||
|
||||
double MainWindow::sigmoid(double x) { return 1 / (1 + exp(-x)); }
|
||||
|
||||
void MainWindow::on_action_triggered() { ui->list->clear(); }
|
28
SoftwareDesign/Lab6/2020114490/mainwindow.h
Normal file
28
SoftwareDesign/Lab6/2020114490/mainwindow.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
private slots:
|
||||
void on_equal_clicked();
|
||||
|
||||
void on_action_triggered();
|
||||
|
||||
private:
|
||||
double sigmoid(double x);
|
||||
Ui::MainWindow *ui;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
190
SoftwareDesign/Lab6/2020114490/mainwindow.ui
Normal file
190
SoftwareDesign/Lab6/2020114490/mainwindow.ui
Normal file
|
@ -0,0 +1,190 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>561</width>
|
||||
<height>419</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>神经元计算器</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="4">
|
||||
<widget class="QPushButton" name="equal">
|
||||
<property name="text">
|
||||
<string>=</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_x0">
|
||||
<property name="text">
|
||||
<string>x0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="x0">
|
||||
<property name="minimum">
|
||||
<double>-1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string>***REMOVED*** 电子1班 ***REMOVED***</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QDoubleSpinBox" name="w1">
|
||||
<property name="minimum">
|
||||
<double>-1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLabel" name="label_his">
|
||||
<property name="text">
|
||||
<string>历史记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QDoubleSpinBox" name="w0">
|
||||
<property name="minimum">
|
||||
<double>-1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>f(x0,x1)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_x1">
|
||||
<property name="text">
|
||||
<string>x1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="6">
|
||||
<widget class="QListWidget" name="list"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_w0">
|
||||
<property name="text">
|
||||
<string>w0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_w1">
|
||||
<property name="text">
|
||||
<string>w1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<widget class="QLineEdit" name="result"/>
|
||||
</item>
|
||||
<item row="5" column="3">
|
||||
<widget class="QDoubleSpinBox" name="b">
|
||||
<property name="minimum">
|
||||
<double>-1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QLabel" name="label_b">
|
||||
<property name="text">
|
||||
<string>b</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="x1">
|
||||
<property name="minimum">
|
||||
<double>-1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>561</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
<property name="title">
|
||||
<string>处理</string>
|
||||
</property>
|
||||
<addaction name="action"/>
|
||||
</widget>
|
||||
<addaction name="menu"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="action">
|
||||
<property name="text">
|
||||
<string>清空历史记录</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>x0</tabstop>
|
||||
<tabstop>x1</tabstop>
|
||||
<tabstop>w0</tabstop>
|
||||
<tabstop>w1</tabstop>
|
||||
<tabstop>b</tabstop>
|
||||
<tabstop>equal</tabstop>
|
||||
<tabstop>list</tabstop>
|
||||
<tabstop>result</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -0,0 +1 @@
|
|||
|
Reference in a new issue