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

📄 testdlg.cpp

📁 将数字1,2,3,4等转换为大写的中文壹,贰等最大可以达到100亿,精确到元
💻 CPP
📖 第 1 页 / 共 5 页
字号:
// testDlg.cpp : implementation file
//

#include "stdafx.h"
#include "test.h"
#include "testDlg.h"

#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
}

CString CTestDlg::Transfertoupper(int number)
{
	
	CString str1=_T("壹");
	CString str2=_T("贰");
	CString str3=_T("叁");
	CString str4=_T("肆");
	CString str5=_T("伍");
	CString str6=_T("陆");
	CString str7=_T("柒");
	CString str8=_T("捌");
	
	CString str9=_T("玖");
	CString str10=_T("拾");
	CString str11=_T("零");
	switch(number)
	{
	case 1:
		return  str1;
	case 2:
		return  str2;
	case 3:
		return  str3;
	case 4:
		return  str4;
	case 5:
		return  str5;
	case 6:
		return  str6;
	case 7:
		return str7;
	case 8:
		return str8;
	case 9:
		return str9;
	case 0:
	default:
		return str10;
	}
	return str10;
}
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()

/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog

CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTestDlg)
	m_zhongbiao = 0.0;
	m_result = _T("");
	m_upper = _T("");
	str2=_T("");
	m_stredit5 = _T("");
	//}}AFX_DATA_INIT
	str2=_T("%");
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTestDlg)
	DDX_Text(pDX, IDC_EDIT1, m_zhongbiao);
	DDV_MinMaxFloat(pDX, m_zhongbiao, 0.f, 1.e+012f);
	DDX_Text(pDX, IDC_EDIT2, m_result);
	DDX_Text(pDX, IDC_EDIT3, m_upper);
	DDX_Text(pDX, IDC_EDIT5, m_stredit5);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
	//{{AFX_MSG_MAP(CTestDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers

BOOL CTestDlg::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 CTestDlg::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 CTestDlg::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 CTestDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CTestDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	float a=0;
	float sum=0;
	CString str;
//	long sum2,sum3;
	CString m_str;
	UpdateData(1);
	if(m_zhongbiao>100)
	{
		a=100*0.015;
		sum=sum+a;
		m_result=_T("100×1.5%");
		if(m_zhongbiao>500)
		{
			a=400*0.011;
			sum=sum+a;
			str=_T("+400×1.1%");
			m_result+=str;
			if(m_zhongbiao>1000)
			{
				a=500*0.008;
				sum=sum+a;
				str=_T("+500×0.8%");
				m_result+=str;
				if(m_zhongbiao>5000)
				{
					a=4000*0.005;
					sum=sum+a;
					str=_T("+4000×0.5%");
					m_result+=str;
					if(m_zhongbiao>10000)
					{
						a=5000*0.0025;
						sum=sum+a;
						str=_T("+5000×0.25%");
						m_result+=str;
						if(m_zhongbiao>100000)
						{
							a=90000*0.0005;
							sum=sum+a;
							str=_T("+90000×0.05%");
							m_result+=str;
							a=(m_zhongbiao-100000)*0.0001;
							sum=sum+a;
							str.Format(_T("+%.0f×0.01%s"),(m_zhongbiao-100000),str2);
							m_result+=str;
							str.Format(_T("=%.4f"),sum);
							m_result+=str;
							goto THEEND;
						}
						else
						{
							a=(m_zhongbiao-10000)*0.0005;
							sum=sum+a;
						//	str.Format(_T("+%f=%f"),a,sum);
						//	m_result+=str;
							str.Format(_T("+%.0f×0.05%s"),(m_zhongbiao-10000),str2);
							m_result+=str;
						//	m_result+=str2;
							str.Format(_T("=%.4f"),sum);
							m_result+=str;
							goto THEEND;
						}
					}
					else
					{
						a=(m_zhongbiao-5000)*0.0025;
						sum=sum+a;
					//	str.Format(_T("+f=%f"),a,sum);
					//	m_result+=str;
						str.Format(_T("+%.0f×0.25%s"),(m_zhongbiao-5000),str2);
						m_result+=str;
						str.Format(_T("=%.4f"),sum);
						m_result+=str;
						goto THEEND;
					}
				}
				else
				{
					a=(m_zhongbiao-1000)*0.005;
					sum=sum+a;
					//str.Format(_T("+%f=%f"),a,sum);
				//	m_result+=str;
					str.Format(_T("+%.0f×0.5%s"),(m_zhongbiao-1000),str2);
					m_result+=str;
					str.Format(_T("=%.4f"),sum);
					m_result+=str;
					goto THEEND;
				}
			}
			else
			{
				a=(m_zhongbiao-500)*0.008;
				sum=sum+a;
			//	str.Format(_T("+%f=%f"),a,sum);
			//	m_result+=str;
		    	str.Format(_T("+%.0f×0.8%s"),(m_zhongbiao-500),str2);
				m_result+=str;
				str.Format(_T("=%.4f"),sum);
				m_result+=str;
				goto THEEND;
			}
		}
		else
		{
		
			a=(m_zhongbiao-100)*0.011;
			sum=sum+a;
		//	sum=sum+0.00005;
			str.Format(_T("+%.0f×1.1%s"),(m_zhongbiao-100),str2);
			m_result+=str;
			str.Format(_T("=%.4f"),sum);
			m_result+=str;
		//	str.Format(_T("=%f"),sum);
		//	m_result+=str;
			goto THEEND;
		}

	}
	else
	{
		sum=m_zhongbiao*0.015;
	//	str.Format(_T("%f×%1.5"),sum);
		str.Format(_T("%.0f×1.5%s=%.4f"),m_zhongbiao,str2,sum);
		m_result=str;
		goto THEEND;
	}
	
THEEND:
	
	m_upper=Transfer(sum);
	m_stredit5=Transfer(m_zhongbiao);
	UpdateData(0);
	
}

void CTestDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
	// TODO: Add your control notification handler code here
	float a=0;
	float sum=0;
	CString str;
	long sum2,sum3;
	CString m_str;
	UpdateData(1);
	if(m_zhongbiao>100)
	{
		a=100*0.015;
		sum=sum+a;
		m_result=_T("100×1.5%");
		if(m_zhongbiao>500)
		{
			a=400*0.008;
			sum=sum+a;
			str=_T("+400×0.8%");
			m_result+=str;
			if(m_zhongbiao>1000)
			{
				a=500*0.0045;
				sum=sum+a;
				str=_T("+500×0.45%");
				m_result+=str;
				if(m_zhongbiao>5000)
				{
					a=4000*0.0025;
					sum=sum+a;
					str=_T("+4000×0.25%");
					m_result+=str;
					if(m_zhongbiao>10000)
					{
						a=5000*0.0010;
						sum=sum+a;
						str=_T("+5000×0.10%");
						m_result+=str;
						if(m_zhongbiao>100000)
						{
							a=90000*0.0005;
							sum=sum+a;
							str=_T("+90000×0.05%");
							m_result+=str;
							a=(m_zhongbiao-100000)*0.0001;
							sum=sum+a;
							str.Format(_T("+%.0f×0.01%s"),(m_zhongbiao-100000),str2);
							m_result+=str;
							str.Format(_T("=%.4f"),sum);
							m_result+=str;
							goto THEEND;
						}
						else
						{
							a=(m_zhongbiao-10000)*0.0005;
							sum=sum+a;
						//	str.Format(_T("+%f=%f"),a,sum);
						//	m_result+=str;
							str.Format(_T("+%.0f×0.05%s"),(m_zhongbiao-10000),str2);
							m_result+=str;
							str.Format(_T("=%.4f"),sum);
							m_result+=str;
							goto THEEND;
						}
					}
					else
					{
						a=(m_zhongbiao-5000)*0.0010;
						sum=sum+a;
					//	str.Format(_T("+f=%f"),a,sum);
					//	m_result+=str;
						str.Format(_T("+%.0f×0.10%s"),(m_zhongbiao-5000),str2);
						m_result+=str;
						str.Format(_T("=%.4f"),sum);
						m_result+=str;
						goto THEEND;
					}
				}
				else
				{
					a=(m_zhongbiao-1000)*0.0025;
					sum=sum+a;
					//str.Format(_T("+%f=%f"),a,sum);
				//	m_result+=str;
					str.Format(_T("+%.0f×0.25%s"),(m_zhongbiao-1000),str2);
					m_result+=str;
					str.Format(_T("=%.4f"),sum);
					m_result+=str;
					goto THEEND;
				}
			}
			else
			{
				a=(m_zhongbiao-500)*0.0045;
				sum=sum+a;
			//	str.Format(_T("+%f=%f"),a,sum);
			//	m_result+=str;
		    	str.Format(_T("+%.0f×0.45%s"),(m_zhongbiao-500),str2);
				m_result+=str;
				str.Format(_T("=%.4f"),sum);
				m_result+=str;
				goto THEEND;
			}
		}
		else
		{
		
			a=(m_zhongbiao-100)*0.008;
			sum=sum+a;
		//	sum=sum+0.00005;
			str.Format(_T("+%.0f×0.80%s"),(m_zhongbiao-100),str2);
			m_result+=str;
			str.Format(_T("=%.4f"),sum);
			m_result+=str;
		//	str.Format(_T("=%f"),sum);
		//	m_result+=str;
			goto THEEND;
		}

	}
	else
	{
		sum=m_zhongbiao*0.015;
	//	str.Format(_T("%f×%1.5"),sum);
		str.Format(_T("%.0f×1.5%s=%.4f"),m_zhongbiao,str2,sum);
		m_result=str;
		goto THEEND;
	}
	
THEEND:
	m_upper=Transfer(sum);
	m_stredit5=Transfer(m_zhongbiao);
	UpdateData(0);
	
}

void CTestDlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
	// TODO: Add your control notification handler code here
	float a=0;
	float sum=0;
	CString str;
	long sum2,sum3;
	CString m_str;
	UpdateData(1);
	if(m_zhongbiao>100)
	{
		a=100*0.010;
		sum=sum+a;
		m_result=_T("100×1.0%");
		if(m_zhongbiao>500)
		{
			a=400*0.007;
			sum=sum+a;
			str=_T("+400×0.70%");
			m_result+=str;
			if(m_zhongbiao>1000)
			{
				a=500*0.0055;
				sum=sum+a;
				str=_T("+500×0.55%");
				m_result+=str;
				if(m_zhongbiao>5000)
				{
					a=4000*0.0035;
					sum=sum+a;
					str=_T("+4000×0.35%");
					m_result+=str;
					if(m_zhongbiao>10000)
					{
						a=5000*0.0020;
						sum=sum+a;
						str=_T("+5000×0.20%");
						m_result+=str;
						if(m_zhongbiao>100000)
						{
							a=90000*0.0005;
							sum=sum+a;
							str=_T("+90000×0.05%");
							m_result+=str;
							a=(m_zhongbiao-100000)*0.0001;
							sum=sum+a;
							str.Format(_T("+%.0f×0.01%s"),(m_zhongbiao-100000),str2);
							m_result+=str;
							str.Format(_T("=%.4f"),sum);
							m_result+=str;
							goto THEEND;
						}
						else
						{
							a=(m_zhongbiao-10000)*0.0005;
							sum=sum+a;
						//	str.Format(_T("+%f=%f"),a,sum);
						//	m_result+=str;
							str.Format(_T("+%.0f×0.05%s"),(m_zhongbiao-10000),str2);
							m_result+=str;
							str.Format(_T("=%.4f"),sum);
							m_result+=str;
							goto THEEND;
						}
					}
					else
					{
						a=(m_zhongbiao-5000)*0.0020;
						sum=sum+a;
					//	str.Format(_T("+f=%f"),a,sum);
					//	m_result+=str;
						str.Format(_T("+%.0f×0.20%s"),(m_zhongbiao-5000),str2);
						m_result+=str;
						str.Format(_T("=%.4f"),sum);
						m_result+=str;
						goto THEEND;
					}
				}
				else
				{
					a=(m_zhongbiao-1000)*0.0035;
					sum=sum+a;
					//str.Format(_T("+%f=%f"),a,sum);
				//	m_result+=str;
					str.Format(_T("+%.0f×0.35%s"),(m_zhongbiao-1000),str2);
					m_result+=str;
					str.Format(_T("=%.4f"),sum);
					m_result+=str;
					goto THEEND;
				}
			}
			else
			{
				a=(m_zhongbiao-500)*0.0055;
				sum=sum+a;
			//	str.Format(_T("+%f=%f"),a,sum);
			//	m_result+=str;
		    	str.Format(_T("+%.0f×0.55%s"),(m_zhongbiao-500),str2);
				m_result+=str;
				str.Format(_T("=%.4f"),sum);
				m_result+=str;
				goto THEEND;
			}
		}
		else
		{

⌨️ 快捷键说明

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