亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? calcdlg.cpp

?? 輸入含數字的式子(可以用多層括號嵌套)
?? CPP
字號:
// CalcDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Calc.h"
#include "CalcDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include<math.h>
/////////////////////////////////////////////////////////////////////////////
// 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()

/////////////////////////////////////////////////////////////////////////////
// CCalcDlg dialog

CCalcDlg::CCalcDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCalcDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCalcDlg)
	m_str = _T("");
	m_answer = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCalcDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCalcDlg)
	DDX_Text(pDX, IDC_EDIT_STR, m_str);
	DDX_Text(pDX, IDC_EDIT_ANSWER, m_answer);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCalcDlg, CDialog)
	//{{AFX_MSG_MAP(CCalcDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_CALC, OnButtonCalc)
	ON_BN_CLICKED(IDC_BUTTON_EXIT, OnButtonExit)
	ON_EN_CHANGE(IDC_EDIT_STR, OnChangeEditStr)
	ON_EN_CHANGE(IDC_EDIT_ANSWER, OnChangeEditAnswer)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCalcDlg message handlers

BOOL CCalcDlg::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
	UpdateData(0);
	return TRUE;  // return TRUE  unless you set the focus to a control
}

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

void CCalcDlg::OnButtonCalc() 
{
	CWaitCursor m_waitcursor;
	BOOL flag=0;int left=0,right=0;
	CString a=m_str.SpanIncluding(".0123456789+-*/^%()");
	if(a.CompareNoCase(m_str))
	{
		MessageBox("輸入的字符中有非法字符");
		flag=1;
	}	
	for(int i=0;i<m_str.GetLength();i++)
	{
		if(m_str.GetAt(i)=='+'||m_str.GetAt(i)=='-'||m_str.GetAt(i)=='*'||m_str.GetAt(i)=='/')
			if(m_str.GetAt(i+1)=='*'||m_str.GetAt(i+1)=='/')
				flag=1;
		if(m_str.GetAt(i)=='*'||m_str.GetAt(i)=='/')
			if(m_str.GetAt(i+1)=='+'||m_str.GetAt(i+1)=='-')
				flag=1;
		if(m_str.GetAt(i)=='(')left++;
		if(m_str.GetAt(i)==')')right++;
	}
	if(left!=right)
	{
		MessageBox("輸入的括號不成對!","抱歉",MB_OK|MB_ICONERROR);
		flag=1;
	}
	if(left>20)
	{
		flag=1;
		MessageBox("輸入的計算式括號不可超過20個!","抱歉",MB_OK|MB_ICONERROR);
	}
if(flag==0)
{
	m_answer=GetFloat(m_str);
	for(int i=m_answer.GetLength()-1;m_answer.GetAt(i)!=46;i--)
		if(m_answer.GetAt(i)==48)
			m_answer.Delete(i);
		if(m_answer.GetAt(m_answer.GetLength()-1)==46)
			m_answer.Delete(m_answer.GetLength()-1);
}
	UpdateData(0);
}

void CCalcDlg::OnButtonExit() 
{
	// TODO: Add your control notification handler code here
	OnOK();	
}

void CCalcDlg::OnChangeEditStr() 
{
	UpdateData(1);	
	m_str.TrimLeft();
	m_str.TrimRight();
	UpdateData(0);	
}



void CCalcDlg::OnChangeEditAnswer() 
{
	UpdateData(0);
}

CString CCalcDlg::GetFloat(CString str)
{
	int count[21][2];for(int i=0;i<10;i++){count[i][0]=-1;count[i][1]=-1;}
	/////以上初始化數組count,使之全為-1
	int cou=0;//用于填充數組count的第一維
	int sgn=0;//用于記錄無用的“(”和“)”,遇“(”加1,遇“)”減1。
	for(i=str.GetLength()-1;i>=0;i--)
	{
		if(str.GetAt(i)==41)
		{
			if(sgn==0)
				count[cou][0]=i;
			sgn++;
		}
		if(str.GetAt(i)==40)
		{
			if(sgn==1)
			{
				count[cou][1]=i;
				cou++;
			}
			sgn--;
		}
	}
	if(cou)
	{
		int kuo=0;CString kuostr,kuoanswer;
		for(kuo=0;kuo<cou;kuo++)
		{
			kuostr=str.Mid(count[kuo][1]+1,count[kuo][0]-count[kuo][1]-1);
//			MessageBox(kuostr);
			kuoanswer=GetFloat(kuostr);
			str.Delete(count[kuo][1],count[kuo][0]-count[kuo][1]+1);
			str.Insert(count[kuo][1],kuoanswer);
			return GetFloat(str);
		}
	}
		//以上得到m_str是幾個(...)組成的
	if(str.GetAt(0)=='+')str.Delete(0);
	if(str.Mid(1).SpanIncluding("0123456789.").GetLength()==str.Mid(1).GetLength())
		return str;

	CString s;s=str;
		for(i=0;i<str.GetLength();i++)//負負得正;“--”號變“+”。
		{
			if(str.GetAt(i)=='-'&&i!=0&&str.GetAt(i+1)=='-')
			{
				str.Delete(i,2);
				str.Insert(i,'+');
			}
		}
		s=str;
		for(i=0;i<str.GetLength();i++)//減法變加法;“-”號變“+-”。
		{
			if(str.GetAt(i)=='-'&&i!=0&&str.GetAt(i-1)!='+'&&str.GetAt(i-1)!='*'&&str.GetAt(i-1)!='/')
				str.Insert(i,'+');
		}
		s=str;
		for(i=0;i<str.GetLength();i++)//去掉多余加號
		{
			if(str.GetAt(i)=='+'&&str.GetAt(i+1)=='+')
			{s.Delete(i);}
		}
		str=s;
	if(cou==0)//式中沒有括號
	{
		double cheng=0;int chengdown=0,chengup=0;
		CString chengstr,strup,strdown;

		double chu=0;int chudown=0,chuup=0;
		CString chustr,struup,strudown;

		double fang=0;int fangdown=0,fangup=0;
		CString fangstr,strfangup,strfangdown;

		double mo=0;int modown=0,moup=0;int mm=0;
		CString mostr,strmup="9",strmdown="8";

		for(i=0;i<str.GetLength();i++)//實現乘方
		{
			if(str.GetAt(i)=='^')
			{
				for(fangup=i-1;fangup>=0;fangup--)
				{
					if(str.GetAt(fangup)<46||str.GetAt(fangup)>57||str.GetAt(fangup)==47)
					{break;	}
					//	strup.Format("%d\n%d",chengup,i);
				}
				for(fangdown=i+2;fangdown<str.GetLength();fangdown++)
				{
					if(str.GetAt(fangdown)<46||str.GetAt(fangdown)>57||str.GetAt(fangdown)==47)
						break;
				}
				break;
			}
		}
		if(fangdown)
		{
			strfangup=str.Mid(fangup+1,i-fangup-1);
			strfangdown=str.Mid(i+1,fangdown-i-1);
//			MessageBox(strdown);

			fang=pow(atof(strfangup),atof(strfangdown));
			fangstr.Format("%10.10f",fang);
			str.Delete(fangup+1,fangdown-fangup-1);
			str.Insert(fangup+1,fangstr);
			return GetFloat(str);
		}



		for(i=0;i<str.GetLength();i++)//實現乘法和除法
		{
			if(str.GetAt(i)=='*')
			{
				for(chengup=i-1;chengup>=0;chengup--)
				{
					if(str.GetAt(chengup)<46||str.GetAt(chengup)>57||str.GetAt(chengup)==47)
					{break;	}
					//	strup.Format("%d\n%d",chengup,i);
				}
				for(chengdown=i+2;chengdown<str.GetLength();chengdown++)
				{
					if(str.GetAt(chengdown)<46||str.GetAt(chengdown)>57||str.GetAt(chengdown)==47)
						break;
				}
				break;
			}

			if(str.GetAt(i)=='/')
			{
				for(chuup=i-1;chuup>=0;chuup--)
				{
					if(str.GetAt(chuup)<46||str.GetAt(chuup)>57||str.GetAt(chuup)==47)
					{break;	}
				}
				for(chudown=i+2;chudown<str.GetLength();chudown++)
				{
					if(str.GetAt(chudown)<46||str.GetAt(chudown)>57||str.GetAt(chudown)==47)
						break;
				}
				break;
			}
		if(str.GetAt(i)=='%')//實現求余
			{
				for(moup=i-1;moup>=0;moup--)
				{
					if(str.GetAt(moup)==47||str.GetAt(moup)<46||str.GetAt(moup)>57)
					{if(str.GetAt(moup)==46)mm=1;break;	}
				}
				for(modown=i+2;modown<str.GetLength();modown++)
				{
					if(str.GetAt(modown)==47||str.GetAt(modown)<46||str.GetAt(modown)>57)
					{	if(str.GetAt(modown)==46)mm=1;break;}
				}
				break;
			}
		}

		if(chengdown)
		{
			strup=str.Mid(chengup+1,i-chengup-1);
			strdown=str.Mid(i+1,chengdown-i-1);
//			MessageBox(strdown);

			cheng=atof(strup)*atof(strdown);
			chengstr.Format("%10.10f",cheng);
			str.Delete(chengup+1,chengdown-chengup-1);
			str.Insert(chengup+1,chengstr);
			return GetFloat(str);
		}



		if(chudown)
		{
			struup=str.Mid(chuup+1,i-chuup-1);
			strudown=str.Mid(i+1,chudown-i-1);
			chu=atof(struup)/atof(strudown);
			chustr.Format("%10.10f",chu);
			str.Delete(chuup+1,chudown-chuup-1);
			str.Insert(chuup+1,chustr);
			return GetFloat(str);
		}

		if(modown)//求余
		{
			strmup=str.Mid(moup+1,i-moup-1);
			strmdown=str.Mid(i+1,modown-i-1);
//			return "Error:小數不可求余";
			mo=atoi(strmup)%atoi(strmdown);
			mostr.Format("%10.10f",mo);
			str.Delete(moup+1,modown-moup-1);
			str.Insert(moup+1,mostr);
			return GetFloat(str);
		}



		for(i=0;i<str.GetLength();i++)//實現加法
		{
			if(str.GetAt(i)=='+')
			{
				CString temp1,temp2;double xx=0;
				temp1=str.Left(i);
				temp2=GetFloat(str.Mid(i+1));
				xx=atof(temp1)+atof(temp2);
				s.Format("%10.10f",xx);
				return s;
			}
		}
	}
	return s;

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性色综合网| 日本人妖一区二区| av成人免费在线| 国产精品人成在线观看免费| 激情五月激情综合网| 欧美一卡在线观看| 美女视频黄a大片欧美| 日韩一区二区免费在线观看| 日韩国产精品91| 91精品国产aⅴ一区二区| 日韩综合小视频| 欧美精品精品一区| 免费观看在线综合| 日韩精品中文字幕一区二区三区 | 欧美日韩国产123区| 一区二区三区精品视频| 欧美亚洲禁片免费| 青青草原综合久久大伊人精品 | 久久电影网站中文字幕| 欧美xxxxxxxx| 大胆亚洲人体视频| 综合色天天鬼久久鬼色| 欧美日韩一级二级| 香港成人在线视频| 欧美电影免费观看高清完整版在 | 亚洲电影一级片| 日韩欧美一区二区在线视频| 国产在线播放一区| 国产精品久久久久影院老司| 在线免费不卡电影| 免费成人性网站| 国产视频视频一区| 91久久精品网| 麻豆91小视频| 亚洲区小说区图片区qvod| 欧美三级电影在线看| 久久se精品一区精品二区| 国产欧美日韩三区| 欧美日韩精品一区二区| 精品一区精品二区高清| 亚洲欧洲日韩综合一区二区| 91精品国产综合久久久久久| 国产一区二区三区香蕉| 亚洲一区二区三区四区的| 日韩欧美一级二级| a级高清视频欧美日韩| 日本视频在线一区| 亚洲裸体在线观看| 日韩精品一区二区三区在线播放 | 日韩一区二区免费在线观看| 成人99免费视频| 亚洲电影第三页| 8x8x8国产精品| 99久久精品免费看国产免费软件| 亚洲综合视频网| 久久精品这里都是精品| 欧美天堂一区二区三区| 国产乱码精品一区二区三区忘忧草| 国产精品水嫩水嫩| 91.com在线观看| 91福利在线导航| 99天天综合性| 国产xxx精品视频大全| 免费的成人av| 丝袜亚洲另类欧美综合| 国产精品久久99| 欧美一区二区三区免费视频| 97se亚洲国产综合自在线观| 国产一本一道久久香蕉| 久久国产免费看| 亚洲国产美女搞黄色| 亚洲视频一区二区在线| 日本一区二区免费在线观看视频| 日韩一级精品视频在线观看| 欧美性色欧美a在线播放| 99久久精品费精品国产一区二区| 国产一区二区三区免费在线观看| 日韩国产欧美在线视频| 亚洲777理论| 亚洲在线观看免费| 亚洲精品网站在线观看| 久久亚洲捆绑美女| 日韩女优毛片在线| 日韩一区二区免费在线观看| 3d动漫精品啪啪一区二区竹菊| 在线区一区二视频| 色综合久久久久| 99riav久久精品riav| 99在线视频精品| 91在线观看美女| 91麻豆视频网站| 一本一道久久a久久精品综合蜜臀| 风间由美性色一区二区三区| 国精品**一区二区三区在线蜜桃| 麻豆国产精品官网| 国产乱一区二区| 高清不卡一二三区| av综合在线播放| 色94色欧美sute亚洲线路二| 色综合久久久久综合99| 欧美在线短视频| 91精品国产一区二区三区| 3d成人动漫网站| 精品福利一区二区三区| 国产亚洲欧洲997久久综合| 中文字幕欧美激情| 亚洲精品视频在线看| 亚洲成人激情综合网| 免费久久精品视频| 国产乱子轮精品视频| av资源站一区| 在线成人av网站| www一区二区| 国产精品久久久久久妇女6080| 久久精品亚洲精品国产欧美| 国产精品人妖ts系列视频| 一级特黄大欧美久久久| 热久久免费视频| 国产69精品一区二区亚洲孕妇| 色综合视频在线观看| 91精品国产福利| 国产精品网站导航| 亚洲素人一区二区| 夜夜精品浪潮av一区二区三区| 亚洲一区二区三区精品在线| 天堂影院一区二区| 久久99精品国产91久久来源| 国产在线看一区| 91在线云播放| 日韩一区二区三区免费观看| 日韩精品一区在线观看| 国产精品久久久久久妇女6080| 亚洲乱码国产乱码精品精小说 | 人人狠狠综合久久亚洲| 懂色av一区二区三区免费观看| 91丨porny丨户外露出| 欧美一二区视频| 一区二区三区在线看| 蜜臀国产一区二区三区在线播放| 精品一区二区三区蜜桃| 欧美影片第一页| 中文文精品字幕一区二区| 首页国产丝袜综合| av网站一区二区三区| 日韩一二三区不卡| 国产精品久久久爽爽爽麻豆色哟哟 | 视频一区二区国产| 成人久久18免费网站麻豆| 欧美理论在线播放| 最好看的中文字幕久久| 国产剧情一区在线| 欧美高清视频不卡网| 综合久久国产九一剧情麻豆| 久久av中文字幕片| 欧美人体做爰大胆视频| 亚洲女爱视频在线| 高清av一区二区| 久久久久青草大香线综合精品| 午夜亚洲国产au精品一区二区| 成人精品视频.| 久久免费的精品国产v∧| 免费欧美日韩国产三级电影| 在线免费观看一区| 亚洲欧美日韩国产一区二区三区| 国产成人综合在线播放| 欧美一区二区三区播放老司机| 亚洲天堂福利av| 不卡的av电影在线观看| 国产视频亚洲色图| 国产尤物一区二区在线| 在线不卡a资源高清| 亚洲电影激情视频网站| 日本久久一区二区| 亚洲影院在线观看| 色哟哟欧美精品| 亚洲精品国产无天堂网2021| 成人99免费视频| 国产精品高清亚洲| 成人黄色一级视频| 国产精品久久久久一区二区三区| 国产成人精品网址| 国产精品久久久久影院亚瑟| 成人免费视频国产在线观看| 久久久久久久免费视频了| 国产精品亚洲专一区二区三区| 精品久久免费看| 国产在线视频精品一区| 久久久久久久久伊人| 粉嫩在线一区二区三区视频| 国产亚洲成av人在线观看导航 | 美女网站在线免费欧美精品| 91精品一区二区三区在线观看| 日日噜噜夜夜狠狠视频欧美人| 91精品国产日韩91久久久久久| 五月婷婷综合激情| 日韩女优制服丝袜电影| 国产精品一品二品| 国产精品久久久久久久久果冻传媒| 99re热这里只有精品免费视频| 亚洲精品亚洲人成人网在线播放|