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

📄 conversion.cpp

📁 关于栈的操作的小程序
💻 CPP
字号:
// Conversion.cpp : implementation file
//

#include "stdafx.h"
#include "CStackOperation.h"
#include "Conversion.h"
#include "math.h"
#include <stdlib.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CConversion dialog


CConversion::CConversion(CWnd* pParent /*=NULL*/)
	: CDialog(CConversion::IDD, pParent)
{
	//{{AFX_DATA_INIT(CConversion)
	m_nInput = 0;
	m_nOutput = 0;
	//}}AFX_DATA_INIT
}


void CConversion::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CConversion)
	DDX_Text(pDX, IDC_INPUT, m_nInput);
	DDX_Text(pDX, IDC_OUTPUT, m_nOutput);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CConversion, CDialog)
	//{{AFX_MSG_MAP(CConversion)
	ON_BN_CLICKED(IDC_TEN_SIXTEEN, OnTenSixteen)
	ON_BN_CLICKED(IDC_TEN_EIGHT, OnTenEight)
	ON_BN_CLICKED(IDC_TEN_SEVEN, OnTenSeven)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CConversion message handlers

void CConversion::OnTenSixteen() 
{
	UpdateData();
	int m_nRes = m_nInput;
	int m_nQuo = m_nInput; 
	while(m_nRes > 0)
	{
		m_nQuo /= 16;
		m_nRes -= m_nQuo*16;
//		if(m_nRes >=10)
//			m_nRes=m_nRes-10+'A';
		s.Push(m_nRes);
		m_nRes = m_nQuo;
		
	}
	int m_n = 0;
	for(int i=s.S.top; i>-1; i--)
	{
		int a = s.Pop();
		m_n =m_n+a*pow(10,i);
	}
		m_nOutput = m_n;
	UpdateData(FALSE);
	

	// TODO: Add your control notification handler code here

}

void CConversion::OnTenEight() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	int m_nRes = m_nInput;
	int m_nQuo = m_nInput; 
	while(m_nRes > 0)
	{
		m_nQuo /= 8;
		m_nRes -= m_nQuo*8;
		s.Push(m_nRes);
		m_nRes = m_nQuo;
	}
	int m_n = 0;
	for(int i=s.S.top; i>-1; i--)
	{
		int a = s.Pop();
		m_n =m_n+a*pow(10,i);
	}
	m_nOutput = m_n;
	UpdateData(FALSE);

}

void CConversion::OnTenSeven() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	int m_nRes = m_nInput;
	int m_nQuo = m_nInput; 
	while(m_nRes > 0)
	{
		m_nQuo /= 7;
		m_nRes -= m_nQuo*7;
		s.Push(m_nRes);
		m_nRes = m_nQuo;
	}
	int m_n = 0;
	for(int i=s.S.top; i>-1; i--)
	{
		int a = s.Pop();
		m_n =m_n+a*pow(10,i);
	}
	m_nOutput = m_n;
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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