sofeh软件算法注册机源码
算法分析@涛之雨main.cpp:
#include "sofeh_hank.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
sofeh_hank w;
w.show();
w.setFixedSize(w.width(), w.height());
return a.exec();
}
sofeh_hank.h
#ifndef SOFEH_HANK_H
#define SOFEH_HANK_H
#include <QtGui/QMainWindow>
#include "ui_sofeh_hank.h"
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include<ctype.h> //需要使用到判断字符的函数
class sofeh_hank : public QMainWindow
{
Q_OBJECT
public:
sofeh_hank(QWidget *parent = 0, Qt::WFlags flags = 0);
~sofeh_hank();
private:
Ui::sofeh_hankClass ui;
private slots:
int register_function();
};
#endif // SOFEH_HANK_H
sofeh_hank.cpp
#include "sofeh_hank.h"
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include<ctype.h> //需要使用到判断字符的函数
sofeh_hank::sofeh_hank(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
connect(ui.pushButton_hank,SIGNAL(clicked(bool)),this,SLOT(register_function()));
}
sofeh_hank::~sofeh_hank()
{
}
int * getSignCode ( long myCode )
{
int mySignedCode= {27,16,47,34},i=0;
static int retSignCode;
for ( ; i<4; i++ )
{
long a,b;
a = myCode;
while ( 1 )
{
b = a * 16 / mySignedCode;
if ( b <= 9999)
break;
a = a /2;
}
retSignCode=b;
//printf ( "%ld", b );
//if(i!=3) printf("-");
}
return retSignCode;
}
int sofeh_hank::register_function()
{
//获取内容并转换为char*数组
QString code_get=ui.lineEdit_maching_code_input->text();
QByteArray ba = code_get.toLatin1();
char *code = ba.data();
//下面是算法
long codeSum = 0;
for (int i=0; i<strlen ( code )+1; i++ )
{
codeSum+=code * ( i+1 );
}
int *regCode=getSignCode ( codeSum );
//然后显示到第二个lineEdit里面
char register_code;
for (int i=0; i<4; i++ )
{
//regCode = regCode + '0';
char gewei = regCode % 10;
char shiwei = (regCode % 100 - gewei)/10;
char baiwei = (regCode % 1000 - shiwei*10-gewei)/100;
char qianwei = (regCode - baiwei*100 - shiwei*10 - gewei)/1000;
register_code = gewei+'0';
register_code = shiwei+'0';
register_code = baiwei+'0';
register_code = qianwei+'0';
register_code = '-';
if(i==3) register_code = 0;
}
ui.lineEdit_register_code->setText(QString(QLatin1String(register_code)));
return 0;
}
ui.h
/********************************************************************************
** Form generated from reading UI file 'sofeh_hank.ui'
**
** Created: Sat May 11 14:53:09 2019
** by: Qt User Interface Compiler version 4.7.3
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SOFEH_HANK_H
#define UI_SOFEH_HANK_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHBoxLayout>
#include <QtGui/QHeaderView>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QToolBar>
#include <QtGui/QVBoxLayout>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class Ui_sofeh_hankClass
{
public:
QWidget *centralWidget;
QWidget *widget;
QVBoxLayout *verticalLayout;
QHBoxLayout *horizontalLayout_2;
QLineEdit *lineEdit_maching_code_input;
QLabel *label;
QPushButton *pushButton_hank;
QHBoxLayout *horizontalLayout;
QLabel *label_2;
QLineEdit *lineEdit_register_code;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *sofeh_hankClass)
{
if (sofeh_hankClass->objectName().isEmpty())
sofeh_hankClass->setObjectName(QString::fromUtf8("sofeh_hankClass"));
sofeh_hankClass->resize(326, 177);
centralWidget = new QWidget(sofeh_hankClass);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
widget = new QWidget(centralWidget);
widget->setObjectName(QString::fromUtf8("widget"));
widget->setGeometry(QRect(50, 20, 215, 81));
verticalLayout = new QVBoxLayout(widget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
horizontalLayout_2 = new QHBoxLayout();
horizontalLayout_2->setSpacing(6);
horizontalLayout_2->setObjectName(QString::fromUtf8("horizontalLayout_2"));
lineEdit_maching_code_input = new QLineEdit(widget);
lineEdit_maching_code_input->setObjectName(QString::fromUtf8("lineEdit_maching_code_input"));
horizontalLayout_2->addWidget(lineEdit_maching_code_input);
label = new QLabel(widget);
label->setObjectName(QString::fromUtf8("label"));
label->setTextFormat(Qt::LogText);
horizontalLayout_2->addWidget(label);
verticalLayout->addLayout(horizontalLayout_2);
pushButton_hank = new QPushButton(widget);
pushButton_hank->setObjectName(QString::fromUtf8("pushButton_hank"));
verticalLayout->addWidget(pushButton_hank);
horizontalLayout = new QHBoxLayout();
horizontalLayout->setSpacing(6);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
label_2 = new QLabel(widget);
label_2->setObjectName(QString::fromUtf8("label_2"));
horizontalLayout->addWidget(label_2);
lineEdit_register_code = new QLineEdit(widget);
lineEdit_register_code->setObjectName(QString::fromUtf8("lineEdit_register_code"));
horizontalLayout->addWidget(lineEdit_register_code);
verticalLayout->addLayout(horizontalLayout);
sofeh_hankClass->setCentralWidget(centralWidget);
menuBar = new QMenuBar(sofeh_hankClass);
menuBar->setObjectName(QString::fromUtf8("menuBar"));
menuBar->setGeometry(QRect(0, 0, 326, 23));
sofeh_hankClass->setMenuBar(menuBar);
mainToolBar = new QToolBar(sofeh_hankClass);
mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
sofeh_hankClass->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(sofeh_hankClass);
statusBar->setObjectName(QString::fromUtf8("statusBar"));
sofeh_hankClass->setStatusBar(statusBar);
retranslateUi(sofeh_hankClass);
QMetaObject::connectSlotsByName(sofeh_hankClass);
} // setupUi
void retranslateUi(QMainWindow *sofeh_hankClass)
{
sofeh_hankClass->setWindowTitle(QApplication::translate("sofeh_hankClass", "sofeh_hank", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("sofeh_hankClass", "\350\257\267\350\276\223\345\205\245\346\234\272\345\231\250\347\240\201", 0, QApplication::UnicodeUTF8));
pushButton_hank->setText(QApplication::translate("sofeh_hankClass", "\347\202\271\346\210\221\350\216\267\345\217\226\346\263\250\345\206\214\347\240\201", 0, QApplication::UnicodeUTF8));
label_2->setText(QApplication::translate("sofeh_hankClass", "\346\263\250\345\206\214\347\240\201\357\274\232", 0, QApplication::UnicodeUTF8));
} // retranslateUi
};
namespace Ui {
class sofeh_hankClass: public Ui_sofeh_hankClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_SOFEH_HANK_H
坐沙发! 建议加上算法流程描述,更有助于理解代码 你这是逼着我写分析啊{:17_1084:}
{:17_1072:}分析还没出来呢。。。
先上算法是什么鬼{:17_1054:}
好吧。。。码分析去了。。。。 咳咳突然想说。。。码完估计也没人看。。。
2333额。。。等着吧。。。
明天考试的时候看看能不能码一波 楼主,你这是QT写的呀,加上注释就跟完美了,可以将源码文件打包分享,谢谢啦 emmmm大型活捉大佬现场!
页:
[1]