📄 jzgqkdlg.cpp
字号:
// jzgqkdlg.cpp : implementation file
//
#include "stdafx.h"
#include "xxgl.h"
#include "jzgqkdlg.h"
#include "strt.h"
#include "ext.h"
#include "func.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int rand1()
{
int b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b;
b0 = rand_base % 2;
b1 = (rand_base % 3) % 2;
b2 = (rand_base % 5) % 2;
b3 = (rand_base % 7) % 2;
b4 = (rand_base % 11) % 2;
b5 = (rand_base % 13) % 2;
b6 = (rand_base % 17) % 2;
b7 = (rand_base % 19) % 2;
b8 = (rand_base % 23) % 2;
b9 = (rand_base % 29) % 2;
b = b9*512 + b8*256 + b7*128 + b6*64 + b5*32 + b4*16 +
b3*8 + b2*4 + b1*2 + b0;
rand_base ++;
return b;
}
int find_a_seat(int max)
{
int i;
int flag;
flag = 0;
while (flag == 0){
i = rand1()%max;
if (process_flag[i] == 0)
flag = 1;
}
return i;
}
Cjzgqkdlg::Cjzgqkdlg(CWnd* pParent /*=NULL*/)
: CDialog(Cjzgqkdlg::IDD, pParent)
{
//{{AFX_DATA_INIT(Cjzgqkdlg)
m_gjjs = 0;
m_zjjs = 0;
m_qtjs = 0;
m_cjjs = 0;
m_jszs = 0;
m_xxmc = _T("");
m_jzjs = 0;
m_zzjs = 0;
//}}AFX_DATA_INIT
FILE *fpe;
unsigned char buf[40];
unsigned char pass[40];
int l,i,c,j,k,flag;
unsigned char mask;
rand_base = 1000;
fpe = fopen("c:\\xxsbgl\\mima.txt","rb");
fscanf(fpe,"%s\n%s\n",buf,pass);
fclose(fpe);
l = strlen((char *)buf);
for (i=0;i<l*8;i++){
c = buf[i/8];
mask = 1;
for (j=0;j<i%8;j++)
mask *= 2;
code[i] = c & mask;
if (code[i] != 0)
code[i] = 1;
}
for (i=0;i<1000;i++)
process_flag[i] = 0;
flag = 0;
j = 0;
while (flag == 0){
i = find_a_seat(l*8);
tab[j] = i;
process_flag[i] = 1;
j ++;
if (j == l*8)
flag = 1;
}
for (i=0;i<l*8;i++){
code6[i] = code[tab[i]];
}
for (i=0;i<l*8;i++)
code[i] = code6[i];
for (i=0;i<l*8;i++){
j = i + l%7;
if (j >= l*8)
j -= l*8;
code1[i] = code[j];
}
for (i=0;i<l*4;i++){
code2[i] = code1[2*i+1];
}
for (i=0;i<l*8;i++){
j = i + l%7;
if (j > l*8)
j -= l*8;
code3[i] = code[j];
}
for (i=0;i<l*4;i++){
code4[i] = code3[2*i];
}
for (i=0;i<l*4;i++)
code5[i] = code2[i] ^ code4[i];
/*
k = 0;
for (i=0;i<l;i++){
c = code5[i*4]*8 + code5[i*4+1]*4 + + code5[i*4+2]*2 + + code5[i*4+3];
if (c < 10)
c += '0';
else
c += 'A' - 10;
pass[k++] = c;
}
pass[k] = 0;
*/
for (i=0;i<l;i++){
c = pass[i];
if (c >= 'A')
c = c - 'A' + 10;
else
c -= '0';
code5[4*i] = c / 8;
c = c % 8;
code5[4*i+1] = c / 4;
c = c % 4;
code5[4*i+2] = c / 2;
code5[4*i+3] = c % 2;
}
for (i=0;i<l*4;i++)
code2[i] = code5[i] ^ code4[i];
for (i=0;i<l*4;i++){
code1[2*i+1] = code2[i];
}
for (i=0;i<l*8;i++){
j = i - l%7;
if (j < 0)
j = j + l*8;
code[i] = code1[j];
}
for (i=0;i<l*8;i++){
code6[tab[i]] = code[i];
}
for (i=0;i<l*8;i++)
code[i] = code6[i];
for (i=0;i<l;i++){
buf[i] = code[i*8] + code[i*8+1]*2 + code[i*8+2]*4 + code[i*8+3]*8
+ code[i*8+4]*16 + code[i*8+5]*32 + code[i*8+6]*64 + code[i*8+7]*128;
}
strcpy(xiaoming,(char *)buf);
m_xxmc = xiaoming;
char buf1[10],buf2[10],buf3[10],buf4[10],buf5[10],buf6[10];
fpe = fopen("c:\\xxsbgl\\jsqk.txt","rb");
if (fpe != NULL){
fscanf(fpe,"%s\n%s\n%s\n%s\n%s\n%s\n",buf1,buf2,buf3,buf4,buf5,buf6);
m_gjjs = atoi(buf1);
m_zjjs = atoi(buf2);
m_cjjs = atoi(buf3);
m_qtjs = atoi(buf4);
m_zzjs = atoi(buf5);
m_jzjs = atoi(buf6);
m_jszs = m_gjjs + m_zjjs + m_cjjs + m_qtjs;
fclose(fpe);
}
}
void Cjzgqkdlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Cjzgqkdlg)
DDX_Text(pDX, IDC_gjjs1, m_gjjs);
DDX_Text(pDX, IDC_zjjs, m_zjjs);
DDX_Text(pDX, IDC_qtjs, m_qtjs);
DDX_Text(pDX, IDC_cjjs, m_cjjs);
DDX_Text(pDX, IDC_jszs, m_jszs);
DDX_Text(pDX, IDC_xxmc, m_xxmc);
DDX_Text(pDX, IDC_jzjs, m_jzjs);
DDX_Text(pDX, IDC_zzjs, m_zzjs);
//}}AFX_DATA_MAP
CBitmap *bitmap;
CBitmap *bitmap1;
HBITMAP hbitmap;
HBITMAP hbitmap1;
bitmap = new CBitmap();
bitmap1 = new CBitmap();
bitmap->LoadBitmap(IDB_qr);
bitmap1->LoadBitmap(IDB_qx);
hbitmap = (*bitmap).operator HBITMAP();
hbitmap1 = (*bitmap1).operator HBITMAP();
CWnd *wn;
CWnd *wn1;
wn = GetDlgItem(IDOK);
wn1 = GetDlgItem(IDCANCEL);
// wn2 = GetDlgItem(IDOK3);
WPARAM wParam;
LPARAM lParam;
wParam = (WPARAM) LOWORD(BS_LEFT | BS_BITMAP); // style
lParam = MAKELPARAM(TRUE, 0); // redraw flag
wn->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap);
wn1->SendMessage(BM_SETIMAGE, IMAGE_BITMAP,(long)hbitmap1);
}
BEGIN_MESSAGE_MAP(Cjzgqkdlg, CDialog)
//{{AFX_MSG_MAP(Cjzgqkdlg)
ON_EN_CHANGE(IDC_gjjs1, OnChangegjjs1)
ON_EN_CHANGE(IDC_zjjs, OnChangezjjs)
ON_EN_CHANGE(IDC_cjjs, OnChangecjjs)
ON_EN_CHANGE(IDC_qtjs, OnChangeqtjs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Cjzgqkdlg message handlers
void Cjzgqkdlg::OnOK()
{
// TODO: Add extra validation here
FILE *fpe;
char buf1[10],buf2[10],buf3[10],buf4[10],buf5[10],buf6[10];
fpe = fopen("c:\\xxsbgl\\jsqk.txt","wb");
GetDlgItemText(IDC_gjjs1,buf1,10);
GetDlgItemText(IDC_zjjs,buf2,10);
GetDlgItemText(IDC_cjjs,buf3,10);
GetDlgItemText(IDC_qtjs,buf4,10);
GetDlgItemText(IDC_zzjs,buf5,10);
GetDlgItemText(IDC_jzjs,buf6,10);
fprintf(fpe,"%s\n%s\n%s\n%s\n%s\n%s\n",buf1,buf2,buf3,buf4,buf5,buf6);
fclose(fpe);
CDialog::OnOK();
}
void Cjzgqkdlg::OnChangegjjs1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
int t1,t2,t3,t4,t;
char buf[10];
GetDlgItemText(IDC_gjjs1,buf,10);
t1 = atoi(buf);
GetDlgItemText(IDC_zjjs,buf,10);
t2 = atoi(buf);
GetDlgItemText(IDC_cjjs,buf,10);
t3 = atoi(buf);
GetDlgItemText(IDC_qtjs,buf,10);
t4 = atoi(buf);
t = t1 + t2 + t3 + t4;
itoa(t,buf,10);
SetDlgItemText(IDC_jszs,buf);
}
void Cjzgqkdlg::OnChangezjjs()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
int t1,t2,t3,t4,t;
char buf[10];
GetDlgItemText(IDC_gjjs1,buf,10);
t1 = atoi(buf);
GetDlgItemText(IDC_zjjs,buf,10);
t2 = atoi(buf);
GetDlgItemText(IDC_cjjs,buf,10);
t3 = atoi(buf);
GetDlgItemText(IDC_qtjs,buf,10);
t4 = atoi(buf);
t = t1 + t2 + t3 + t4;
itoa(t,buf,10);
SetDlgItemText(IDC_jszs,buf);
}
void Cjzgqkdlg::OnChangecjjs()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
int t1,t2,t3,t4,t;
char buf[10];
GetDlgItemText(IDC_gjjs1,buf,10);
t1 = atoi(buf);
GetDlgItemText(IDC_zjjs,buf,10);
t2 = atoi(buf);
GetDlgItemText(IDC_cjjs,buf,10);
t3 = atoi(buf);
GetDlgItemText(IDC_qtjs,buf,10);
t4 = atoi(buf);
t = t1 + t2 + t3 + t4;
itoa(t,buf,10);
SetDlgItemText(IDC_jszs,buf);
}
void Cjzgqkdlg::OnChangeqtjs()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
int t1,t2,t3,t4,t;
char buf[10];
GetDlgItemText(IDC_gjjs1,buf,10);
t1 = atoi(buf);
GetDlgItemText(IDC_zjjs,buf,10);
t2 = atoi(buf);
GetDlgItemText(IDC_cjjs,buf,10);
t3 = atoi(buf);
GetDlgItemText(IDC_qtjs,buf,10);
t4 = atoi(buf);
t = t1 + t2 + t3 + t4;
itoa(t,buf,10);
SetDlgItemText(IDC_jszs,buf);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -