Hanshushixian. Obj: error LNK2001: unresolved external symbol "bool __cdecl GetTop (struct SqStackN *, double & amp;) "(? GetTop @ @ YA_NPAUSqStackN @ @ AAN @ Z)
Hanshushixian. Obj: error LNK2001: unresolved external symbol "bool __cdecl Push (struct SqStackN * & amp; , double) "(? Push @ @ YA_NAAPAUSqStackN @ @ N @ Z)
Hanshushixian. Obj: error LNK2001: unresolved external symbol "bool __cdecl Pop (struct SqStackN * & amp; , double & amp;) "(? Pop @ @ YA_NAAPAUSqStackN @ @ AAN @ Z)
Hanshushixian. Obj: error LNK2001: unresolved external symbol "void __cdecl initStack (struct SqStackN * & amp;) "(? InitStack @ @ YAXAAPAUSqStackN @ @ @ Z)
The Debug/y8210181709. Exe: fatal error LNK1120:5 unresolved externals
An error occurred when execution link. Exe.
Basic idea is to have a stack, calculated, using the stack in the stack calculation error postfix expression, vc error is above, below is my stack suffix function calculation,
Double calculate (char * postexp)
{
Double a, b, c, d, e;
SqStackN * o; InitStack (o);
While (* postexp!='\ 0')
{
The switch (* postexp)
{
Case: '+'
Pop (o, a);
Pop (o, b);
C=b + a;
Push (o, c);
break;
In case the '-' :
Pop (o, a);
Pop (o, b);
C=b - a;
Push (o, c);
break;
Case: '*'
Pop (o, a);
Pop (o, b);
C=b * a;
Push (o, c);
break;
Case '/' :
Pop (o, a);
Pop (o, b);
If (a!=0)
{
C=b/a;
Push (o, c);
break;
}
The else
{
exit(0);
}
break;
Default:
D=0;
While (* postexp>='0' & amp; & * postexp<='9')
{
D=d * 10 + (* postexp - '0');
Postexp++;
}
Push (o, d);
break;
}
Postexp++;
}
GetTop (o, e);
DestroyStack (o);
Return (e);
}
CodePudding user response:
Fyi:# pragma warning (4996) disable:
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Functional calculator (vc + + 6.0, the Win32 Console)
Function:
Currently provides more than 10 common mathematical functions:
(1) sinusoidal sin
2 cosine cos
(3) tangent tan
(4) open square SQRT
5] arcsine arcsin
[6] the arccosine arccos
Once the arctangent arctan
Being common logarithm lg
'levies natural logarithm ln
Exp. ⑽ e index
⑾ been function ^
⑿ rounded up ceil
[13] the whole floor down
[14] round round round
Usage:
If asked 32 times the power of 2, can break into 2 ^ 32 & lt; Enter & gt;
If asked 30 degrees of tangent type tan (Pi/6) & lt; Enter & gt;
Note not scored: tan (30) & lt; Enter>
If required 1.23 radians sine, there are several approaches are effective:
Sin (1.23) & lt; Enter>
Sin 1.23 & lt; Enter>
Sin1.23 & lt; Enter>
If verification is cosine formula of sum of squares can be into sin (1.23) ^ 2 + cos (1.23) ^ 2 & lt; Enter> Or sin1.23 ^ 2 + cos1.23 ^ 2 & lt; Enter>
In addition two function together, automatic understanding for multiplication, such as: sin1.23 cos0.77 + cos1.23 sin0.77 is equivalent to the sin (1.23) * cos (0.77) + cos (1.23) * sin (0.77)
Of course, you can also be based on the triangle transform, reoccupy sin (1.23 + 0.77) or sin2 verify,
This calculator so give full consideration to the operator priority, such as: 2 + 3 * 4 ^ 2 effectively: 2 + (3) * (4 * 4)
In addition the function name if it is in front of the Numbers, then automatically think people.
Likewise, if a number is the right of the left parenthesis, automatically think that the number and implied a multiplication sign between a bracket,
Such as: 3 sin1. 2 ^ 2 + 5 cos2. 1 ^ 2 to 3 * sin2 + 5 * cos2 (1.2) (2.1)
Such as: 4 (3-2 (sqrt5-1) + ln2) + lg5 equivalent to 4 * (2 * 3-5 () - 1) + loge (2)) + log10 (5)
In addition, the calculator provides a Pi type letters case-insensitive, for ease of use,
Hexadecimal integer begin with 0 x or 0 x,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
Const char Tab=0 x9;
Const int DIGIT=1;
Const int MAXLEN=16384;
Char s [MAXLEN], * endss;
Int PCS=15;
Double round (double dVal, short iPlaces) {//iPlaces>=0
Char s [30];
Double dRetval;
Sprintf (s, "%. * lf iPlaces, dVal);
Sscanf (s, "% lf", & amp; DRetval);
Return (dRetval);
}
Double fun (double x, char op [], int * iop) {
While (op iop [* 1] <32)//the bank make function calls without nested parentheses, such as arc sin (sin (1.234)) simply type arc sin sin 1.234 & lt; Enter>
The switch (op iop [* 1]) {
Case 7: x=sin (x); (* iop) -; break;
Case 8: x=cos (x); (* iop) -; break;
Case 9: x=tan (x); (* iop) -; break;
Case 10: x=SQRT (x); (* iop) -; break;
Case 11: x=asin (x); (* iop) -; break;
Case 12: x=a cosine (x); (* iop) -; break;
Case 13: x=atan (x); (* iop) -; break;
Case 14: x=log10 (x); (* iop) -; break;
Case: 15 x=log (x); (* iop) -; break;
Case: 16 x=exp (x); (* iop) -; break;
Case 17: x=ceil (x); (* iop) -; break;
Case: 18 x=floor (x); (* iop) -; break;
Case: 19 x=round (x, 0); (* iop) -; break;
}
Return the x;
}
Double calc (char * expr, char * * addr) {
Static int deep;//the recursion depth
Static char * fname []={" sin ", "cos", "tan", "SQRT", "arcsin", "arccos", "arctan", "lg", "ln", "exp", "ceil", "floor", "round", NULL};
Double ST [10]={0.0};//digital stack
Char op [10]={' + '};//operator stack
Rexp char c, * and * pp, * pf;
Int ist=1, iop=1, the last, I, n.
__int64 i64;
if (! Deep) {
Pp=pf=expr;
Do {
C=* pp++;
If (c!=' '& amp; & C!!!=Tab)
* pf++=c;
} while (c!='\ 0');
}
Pp=expr;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull