⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xixibmdlg.cpp

📁 香农编码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// xixibmDlg.cpp : implementation file
//

#include "stdafx.h"
#include "xixibm.h"
#include "xixibmDlg.h"
#include "cmath"
#include "time.h"
#include "stdlib.h"
#include   <iostream.h>   
#include   <math.h>   
#include   <stdlib.h>   
#include   <malloc.h>   
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

    
  static      Result   result[7];    
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()

/////////////////////////////////////////////////////////////////////////////
// CXixibmDlg dialog

CXixibmDlg::CXixibmDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CXixibmDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXixibmDlg)
	a1 = 0.0;
	a2 = 0.0;
	a3 = 0.0;
	a4 = 0.0;
	a5 = 0.0;
	a6 = 0.0;
	a7 = 0.0;
	b1 = 0.0;
	b2 = 0.0;
	b3 = 0.0;
	b4 = 0.0;
	b5 = 0.0;
	b6 = 0.0;
	b7 = 0.0;
	c1 = 0.0;
	c2 = 0.0;
	c3 = 0.0;
	c4 = 0.0;
	c5 = 0.0;
	c6 = 0.0;
	c7 = 0.0;
	d1 = 0.0;
	d2 = 0.0;
	d3 = 0.0;
	d4 = 0.0;
	d5 = 0.0;
	d6 = 0.0;
	d7 = 0.0;
	e1 = _T("");
	e2 = _T("");
	e3 = _T("");
	e4 = _T("");
	e5 = _T("");
	e6 = _T("");
	mc = 0.0;
	xl = 0.0;
	e7 = _T("");
	i7 = _T("");
	i6 = _T("");
	i5 = _T("");
	i4 = _T("");
	i3 = _T("");
	i2 = _T("");
	i1 = _T("");
	h7 = 0;
	h6 = 0;
	h5 = 0;
	h4 = 0;
	h3 = 0;
	h2 = 0;
	h1 = 0;
	g7 = _T("");
	g6 = _T("");
	g5 = _T("");
	g4 = _T("");
	g3 = _T("");
	g2 = _T("");
	g1 = _T("");
	m1 =1;
	m2 =2;
	m3 =3;
	m4 =4;
	m5 =5;
	m6 =6;
	m7 =7;
	xys = 0.0;
	f1 = 0;
	f2 = 0;
	f3 = 0;
	f4 = 0;
	f5 = 0;
	f6 = 0;
	f7 = 0;
	mcfn = 0.0;
	mchfm = 0.0;
	xlfn = 0.0;
	xlhfm = 0.0;
	//js[0]=0;js[1]=0;js[2]=0;js[3]=0;js[4]=0;js[5]=0;js[6]=0;
	//no[0]=1;no[1]=2;no[2]=3;no[3]=4;no[4]=5;no[5]=6;no[6]=7;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CXixibmDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXixibmDlg)
	DDX_Text(pDX, IDC_EDITa1, a1);
	DDV_MinMaxDouble(pDX, a1, 0., 1.);
	DDX_Text(pDX, IDC_EDITa2, a2);
	DDV_MinMaxDouble(pDX, a2, 0., 1.);
	DDX_Text(pDX, IDC_EDITa3, a3);
	DDV_MinMaxDouble(pDX, a3, 0., 1.);
	DDX_Text(pDX, IDC_EDITa4, a4);
	DDV_MinMaxDouble(pDX, a4, 0., 1.);
	DDX_Text(pDX, IDC_EDITa5, a5);
	DDV_MinMaxDouble(pDX, a5, 0., 1.);
	DDX_Text(pDX, IDC_EDITa6, a6);
	DDV_MinMaxDouble(pDX, a6, 0., 1.);
	DDX_Text(pDX, IDC_EDITa7, a7);
	DDV_MinMaxDouble(pDX, a7, 0., 1.);
	DDX_Text(pDX, IDC_EDITb1, b1);
	DDX_Text(pDX, IDC_EDITb2, b2);
	DDX_Text(pDX, IDC_EDITb3, b3);
	DDX_Text(pDX, IDC_EDITb4, b4);
	DDX_Text(pDX, IDC_EDITb5, b5);
	DDX_Text(pDX, IDC_EDITb6, b6);
	DDX_Text(pDX, IDC_EDITb7, b7);
	DDX_Text(pDX, IDC_EDITc1, c1);
	DDX_Text(pDX, IDC_EDITc2, c2);
	DDX_Text(pDX, IDC_EDITc3, c3);
	DDX_Text(pDX, IDC_EDITc4, c4);
	DDX_Text(pDX, IDC_EDITc5, c5);
	DDX_Text(pDX, IDC_EDITc6, c6);
	DDX_Text(pDX, IDC_EDITc7, c7);
	DDX_Text(pDX, IDC_EDITd1, d1);
	DDX_Text(pDX, IDC_EDITd2, d2);
	DDX_Text(pDX, IDC_EDITd3, d3);
	DDX_Text(pDX, IDC_EDITd4, d4);
	DDX_Text(pDX, IDC_EDITd5, d5);
	DDX_Text(pDX, IDC_EDITd6, d6);
	DDX_Text(pDX, IDC_EDITd7, d7);
	DDX_Text(pDX, IDC_EDITe1, e1);
	DDX_Text(pDX, IDC_EDITe2, e2);
	DDX_Text(pDX, IDC_EDITe3, e3);
	DDX_Text(pDX, IDC_EDITe4, e4);
	DDX_Text(pDX, IDC_EDITe5, e5);
	DDX_Text(pDX, IDC_EDITe6, e6);
	DDX_Text(pDX, IDC_EDITmachang, mc);
	DDX_Text(pDX, IDC_EDITxiaolv, xl);
	DDX_Text(pDX, IDC_EDITe7, e7);
	DDX_Text(pDX, IDC_EDITi7, i7);
	DDX_Text(pDX, IDC_EDITi6, i6);
	DDX_Text(pDX, IDC_EDITi5, i5);
	DDX_Text(pDX, IDC_EDITi4, i4);
	DDX_Text(pDX, IDC_EDITi3, i3);
	DDX_Text(pDX, IDC_EDITi2, i2);
	DDX_Text(pDX, IDC_EDITi1, i1);
	DDX_Text(pDX, IDC_EDITh7, h7);
	DDX_Text(pDX, IDC_EDITh6, h6);
	DDX_Text(pDX, IDC_EDITh5, h5);
	DDX_Text(pDX, IDC_EDITh4, h4);
	DDX_Text(pDX, IDC_EDITh3, h3);
	DDX_Text(pDX, IDC_EDITh2, h2);
	DDX_Text(pDX, IDC_EDITh1, h1);
	DDX_Text(pDX, IDC_EDITg7, g7);
	DDX_Text(pDX, IDC_EDITg6, g6);
	DDX_Text(pDX, IDC_EDITg5, g5);
	DDX_Text(pDX, IDC_EDITg4, g4);
	DDX_Text(pDX, IDC_EDITg3, g3);
	DDX_Text(pDX, IDC_EDITg2, g2);
	DDX_Text(pDX, IDC_EDITg1, g1);
	DDX_Text(pDX, IDC_EDIT11, m1);
	DDX_Text(pDX, IDC_EDIT22, m2);
	DDX_Text(pDX, IDC_EDIT33, m3);
	DDX_Text(pDX, IDC_EDIT44, m4);
	DDX_Text(pDX, IDC_EDIT55, m5);
	DDX_Text(pDX, IDC_EDIT66, m6);
	DDX_Text(pDX, IDC_EDIT77, m7);
	DDX_Text(pDX, IDC_EDITxiyuanshang, xys);
	DDX_Text(pDX, IDC_EDITf1, f1);
	DDX_Text(pDX, IDC_EDITf2, f2);
	DDX_Text(pDX, IDC_EDITf3, f3);
	DDX_Text(pDX, IDC_EDITf4, f4);
	DDX_Text(pDX, IDC_EDITf5, f5);
	DDX_Text(pDX, IDC_EDITf6, f6);
	DDX_Text(pDX, IDC_EDITf7, f7);
	DDX_Text(pDX, IDC_EDITmachangfeinuo, mcfn);
	DDX_Text(pDX, IDC_EDITmachanghfm, mchfm);
	DDX_Text(pDX, IDC_EDITxiaolvfeinuo, xlfn);
	DDX_Text(pDX, IDC_EDITxiaolvhfm, xlhfm);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CXixibmDlg, CDialog)
	//{{AFX_MSG_MAP(CXixibmDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_DESTROY()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON2, Onbianma)
	ON_BN_CLICKED(IDC_BUTTON3, Onclearall)
	ON_BN_CLICKED(IDC_BUTTON1, Onhelp)
	ON_BN_CLICKED(IDC_BUTTON4, Onaboutme)
	ON_BN_CLICKED(IDC_BUTTON5, Onfeipei)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXixibmDlg message handlers

BOOL CXixibmDlg::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
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CXixibmDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

void CXixibmDlg::OnDestroy()
{
	WinHelp(0L, HELP_QUIT);
	CDialog::OnDestroy();
}

// 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 CXixibmDlg::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 CXixibmDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
//===================================================================================
void CXixibmDlg::Onbianma() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	m1=1;m2=2;m3=3;m4=4;m5=5;m6=6;m7=7;//初始化信源符号
	no[0]=1;no[1]=2;no[2]=3;no[3]=4;no[4]=5;no[5]=6;no[6]=7;
	if (a1==0||a2==0||a3==0||a4==0||a5==0||a6==0||a7==0) MessageBox("你还没有填完呢!");
	else 
	{
	     if ((a1+a2+a3+a4+a5+a6+a7)>1.00001||(a1+a2+a3+a4+a5+a6+a7)<0.99999)
		 //if (a1+a2+a3+a4+a5+a6+a7-1<0.0001)
		{MessageBox("概率之和不为1,请修改!");}			
	  else 
	  {
		  ay[0]=a1;ay[1]=a2;ay[2]=a3;ay[3]=a4;ay[4]=a5;ay[5]=a6;ay[6]=a7;
	        paixu();duishu();machang();ljgl();bianma();bmxl();diaoyong();feixiaolv();dyhuffman();hfmmc();
			
            UpdateData(false);
		}   
	}
}

void CXixibmDlg::Onclearall() 
{
	// TODO: Add your control notification handler code here
	clear();
     UpdateData(false);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -