Home > Software engineering >  How to add in the MFC project has written a c program?? Seek help from a great god!
How to add in the MFC project has written a c program?? Seek help from a great god!

Time:09-23

Purpose is to make up a visualization of the calculator, using c + + has the function to achieve, but how can I=button through a visual interface, the visual interface of the string to the c + + programs, and then run, and output in the visual interface?? Or, there is a better way,

CodePudding user response:

https://www.cnblogs.com/liufei1983/p/7140634.html

CodePudding user response:

See the second floor, or can now directly the computer application system at the set to your MFC application

CodePudding user response:

Interface is mainly MFC dialog box, etc., add controls, and then obtain corresponding data, etc., and then call c + + calculation logic

CodePudding user response:

//I see you give me advice, but the feeling is not start!!!!! I'd better directly on the code,,, this is I use an array of stack of calculator
 # include 
#include
#include
using namespace std;
//enum Boolean {FALSE, TRUE};
//typedef enum Boolean Bool;
Struct stack {
Int top;
Double * a;
Int size;
};
Typedef struct stack stack;
Void Initstack (Stack *, int sz);
Void Free (Stack *);
Int a Push (Stack *, int);
Pop (Stack is int *);
Double Gettop (Stack *);
Void Makempty (Stack *);
Boolean Isempty (Stack *);
Bool Isfull (Stack *);
Stack s1, s2;
Void Free (Stack * S)
{
Free (S - & gt; A);
}
Void Makempty (Stack * S)
{
S - & gt; Top=1;
}
Boolean Isempty (Stack * S)
{
Return (bool) (S - & gt; Top==1);
}
Void Initstack (Stack * S, int sz)
{
S - & gt; Size=sz.
S - & gt; A=(double *) malloc (sizeof (double) * S - & gt; The size);
S - & gt; Top=1;
}
Int a Push (Stack * S, double nu)
{
if(! Isfull (S)) {
S - & gt; A [+ + (S - & gt; top)]=nu;
return 0;
}
The else return - 1;
}
Int a Push (Stack * S, int nu)
{
if(! Isfull (S)) {
S - & gt; A [+ + (S - & gt; top)]=nu;
return 0;
}
The else return - 1;
}
Pop (Stack is int * S)
{
if(! Isempty (S)) {
The return of S - & gt; A [(S - & gt; top) -];
}
The else
{
Cout<& lt;" An empty stack ";
exit(1);
}
}
Double Gettop (Stack * S) {
if(! Isempty (S))
{
The return of S - & gt; A/S - & gt; top;
}
The else
{
Cout<& lt;" An empty stack ";
exit(1);
}
}
Bool Isfull (Stack * S)
{
Return (bool) (S - & gt; Top==S - & gt; Size - 1);
}
Double CAL (Stack * s1, s2 Stack *)
{
Double m, n;
If ((int) Gettop (s2)=='(')
{
Pop (s2);
return 0;
}
M=Gettop (s1);
Pop (s1);
N=Gettop (s1);
Pop (s1);
The switch ((int) Gettop (s2))
{
Case '+' : Push (s1, m + n);
Pop (s2);
break;
Case '-' : Push (s1, n - m);
Pop (s2);
break;
Case '*' : Push (s1, m * n);
Pop (s2);
break;
Case '/' : Push (s1, n/m);
Pop (s2);
break;
Case '%' : Push (s1, (double) (int) ((int) n % m));
Pop (s2);
break;
Case '^' : Push (s1, pow (n, m));
Pop (s2);
break;
Default:
Pop (s2);
}
Return Gettop (s1);
}
Int main ()
{
Stack * s1=(Stack *) malloc (sizeof (Stack));
Stack * s2=(Stack *) malloc (sizeof (Stack));
Initstack (s1, 100);
Initstack (s2, 100);
Char x [1000];
cin> X + 1;
Int a=strlen (x);
X='(' x [0], [a]=') ', x a + [1]='\ 0';
int i;
Double k=0;
Int tp=10;
for(i=0; X [I]!='\ 0'; I++) {
If (x [I] & gt;='0' & amp; & X [I] <[I]='9' | | x=='. ') {
K=k + tp * x [I] - '0';
If (x + 1] [I=='. ') {
Tp=0.1;
I=I + 2;
K=k + 0.1 * (x [I] - '0');
While (x + 1] [I & gt;='0' & amp; & [I x + 1] <='9') {
K=k + 0.1 * (x [I] - '0');
i++;
}
}

}
Else if (x==[I] '^') {
While (k!=0)
{Push (s1, k);
K=0;
Tp=10; }
Push (s2, x [I]);
i++;
Push (s1, (double) (x [I] - '0'));
CAL (s1, s2);
}
Else if (x [I]! '=') & amp; & X [I]! )
='^'{
While (k!=0)
{Push (s1, k);
K=0;
Tp=10; }
If (Isempty (s2))
Push (s2, x [I]);

Else if (Gettop (s2)=='*' | | Gettop (s2)=='/' | | Gettop (s2)=='%') {
If (x [I]=='(')
Push (s2, x [I]);
Else if (x [I]=='*' | | x [I]=='/') {
CAL (s1, s2);
While (Gettop (s2)=='*' | | Gettop (s2)=='/')
{
CAL (s1, s2);
}
Push (s2, x [I]);
}
The else {
CAL (s1, s2);
While (Gettop (s2)=='+' | | Gettop (s2)=='-') {
CAL (s1, s2);
}
Push (s2, x [I]);
}}
Else if (Gettop (s2)=='+' | | Gettop (s2)=='-') {
If (x [I]=='(' | | x [I]==' * '| | x [I]=='/' | | x [I]=='%')
Push (s2, x [I]);
The else
{
CAL (s1, s2);
Push (s2, x [I]);
}

}
Else if ((Gettop (s2)=='(')) {
If (x [I]! )
=') 'Push (s2, x [I]);
}
}
The else {
While (k!=0)
{Push (s1, k);
K=0;
Tp=10; }
While (Gettop (s2)!='(')
CAL (s1, s2);
Pop (s2);
}}
Coutreturn 0;
}

CodePudding user response:

Then this is a MFC of Dlg. CPP, button18 corresponding response function is a "=",,,
 # include "stdafx. H" 
# include "MFCApplication1. H"
# include "MFCApplication1Dlg. H"
# include "afxdialogex. H"
# ifdef _DEBUG
# define new DEBUG_NEW
# endif


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related