?? 七星彩2dlg.cpp
字號:
// 七星彩2Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "七星彩2.h"
#include "七星彩2Dlg.h"
#define N 7
#define KK 30
#define SX 4
#define SY 4
char m1[N+2][N+2],m2[N+2][N+2];
char s[N][N];
char t[N];
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy2Dlg dialog
CMy2Dlg::CMy2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CMy2Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMy2Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMy2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMy2Dlg)
DDX_Control(pDX, IDC_SPIN2, m_zzz);
DDX_Control(pDX, IDC_PROGRESS1, m_ppp);
DDX_Control(pDX, IDC_SPIN1, m_nnn);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMy2Dlg, CDialog)
//{{AFX_MSG_MAP(CMy2Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy2Dlg message handlers
BOOL CMy2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_nnn.SetBuddy(GetDlgItem(IDC_EDIT1));
m_nnn.SetRange(1,60);///////////////////////////////////////////////////////////
m_nnn.SetPos(59);
m_zzz.SetBuddy(GetDlgItem(IDC_EDIT2));
m_zzz.SetRange(0,N+1);///////////////////////////////////////////////////////////
m_zzz.SetPos(0);
m_ppp.SetRange(0,100);
return TRUE; // return TRUE unless you set the focus to a control
}
void CMy2Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMy2Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy2Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void readd()
{
int k,u;
CFile fp;
fp.Open("七彩星歷史紀錄.txt",CFile::modeRead);
for(k=N;k>0;k--)
{
fp.Seek(-(k*N+k*2L),CFile::end);
fp.Read(t,N);
for(u=0;u<N;u++)
s[N-k][u]=t[u]-'0';
}
}
void initm()
{
int a,b;
for(a=0;a<N+2;a++)
for(b=0;b<N+2;b++)
m1[a][b]=0;
for(a=1;a<N+1;a++)
for(b=1;b<N+1;b++)
m1[a][b]=s[a-1][b-1];
}
int jjj(int a,int b)
{
int m,n,u,v,s=0;
for(m=-1;m<2;m++)
for(n=-1;n<2;n++)
{
u=a+m;v=b+n;
if(u<0||u>N+1||v<0||v>N+1) continue;
s+=m1[u][v];
}
return(s%10);
}
void m1tom2()
{
int a,b;
for(a=0;a<N+2;a++)
for(b=0;b<N+2;b++)
m2[a][b]=jjj(a,b);
}
void m2tom1()
{
int a,b;
for(a=0;a<N+2;a++)
for(b=0;b<N+2;b++)
m1[a][b]=m2[a][b];
}
void CMy2Dlg::OnOK()
{
// TODO: Add extra validation here
int n,k,a,b,z;
CString ss;
char st[]="\r\n";
CFile fp,fpt;
fp.Open("七彩星號碼全.txt",CFile::modeCreate|CFile::modeWrite);
fpt.Open("七彩星號碼單.txt",CFile::modeCreate|CFile::modeWrite);
readd();
initm();
n=m_nnn.GetPos();
z=m_zzz.GetPos();
for(k=0;k<n;k++)
{
m1tom2();
m2tom1();
draw();
ss.Format("%d\r\n\r\n",k+1);
fp.Write(ss,ss.GetLength());
for(a=0;a<=N+1;a++)/////////////////////////////////
{
for(b=1;b<N+1;b++)
t[b-1]=m1[a][b]+'0';
fp.Write(t,N);
fp.Write(st,2);
if(a+z==N+1)
{
fpt.Write(t,N);
fpt.Write(st,2);
}
}
fp.Write(st,2);
m_ppp.SetPos(100*(k+1)/n);
}
fp.Close();
fpt.Close();
}
void CMy2Dlg::draw()
{
int a,b,u,v;
CClientDC p(this);
for(a=0;a<N+2;a++)
for(b=0;b<N+2;b++)
{
for(u=0;u<KK;u++)
for(v=0;v<KK;v++)
p.SetPixelV(SX+a*KK+u,SY+b*KK+v,m1[a][b]*255/9*(65536+256+1));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -