C + + logic expression operation Logical expression operation The logical expression is composed of capital English letters and symbols ~, *, +, (). The three symbols represent logical not, and, or operation respectively. English letters represent variables. Variables have two possible values. False (0) or true (1), *, +, () can change the operation order of the expression and can be nested. A program is compiled to calculate the value of the logical expression [input format] The input is in several lines First line string s (1)

C + + logic expression operation Logical expression operation The logical expression is composed of capital English letters and symbols ~, *, +, (). The three symbols represent logical not, and, or operation respectively. English letters represent variables. Variables have two possible values. False (0) or true (1), *, +, () can change the operation order of the expression and can be nested. A program is compiled to calculate the value of the logical expression [input format] The input is in several lines First line string s (1)


#include
using namespace std;
#define MAXSIZE 100
#define CHARNUM 26
//Define stack structure
typedef struct _ stack
{
char data[MAXSIZE];
int top;
} stack;
//Converts the input logical expression string to an inverse Polish string
void translate(const char *p,char *pout)
{
stack op;
op.top= -1;
int i=0;
while (*p!='\0')
{
switch (*p)
{
case '(':
op.data [++ op.top ]=*p;
*p++;
break;
case ')':
while ( op.data [ op.top ]!='(')
{
pout[i++]= op.data [ op.top ];
op.top --;
}
op.top --;
*p++;
break;
case ':
op.data [++ op.top ]=*p;
*p++;
break;
case '*':
case '+':
while (( op.top !=-1)&&( op.data [ op.top ]!='('))
{
pout[i++]= op.data [ op.top ];
op.top --;
}
op.data [++ op.top ]=*p;
*p++;
break;
case ' ':
break;
default:
pout[i++]=*p;
*p++;
}
}
while ( op.top !=-1)
{
pout[i++]= op.data [ op.top ];
op.top --;
}
pout[i]='\0';
}
//Solution of inverse Polish equation
bool calculator(const char* str)
{
stack st;
st.top= -1;
char ch0,ch1,c;
while (*str!='\0')
{
switch (*str)
{
case '0':
case '1':
st.data [++ st.top ]=*str;
break;
case ':
ch0= st.data [ st.top --];
c=!(ch0-'0')+'0';
st.data [++ st.top ]=c;
break;
case '+':
ch0= st.data [ st.top --];
ch1= st.data [ st.top --];
c=((ch0-'0')||(ch1-'0'))+'0';
st.data [++ st.top ]=c;
break;
case '*':
ch0= st.data [ st.top --];
ch1= st.data [ st.top --];
c=((ch0-'0')&&(ch1-'1'))+'0';
st.data [++ st.top ]=c;
break;
default:
break;
}
*str++;
}
return st.data [ st.top ]-'0';
}
int main()
{
char str[MAXSIZE]={0};
int chartab[CHARNUM]={0};
fstream infile;
fstream outfile;
int sum;
//Open input and output files
infile.open (" stackc.in ",fstream::in);
outfile.open (" stackc.out ",fstream::out);
//Gets the first line of string
infile.getline (str,MAXSIZE);
//Gets the second line of integers
sum= infile.get ()-'0';
infile.get ();
//Get the value of each variable
for (int i=0;i



On the expression of logical operation
Suppose a = true, B = false, C = true, d = true, the value of logic operation expression is true {(a ∧ b) ∨ (C ∧ d)}
The meaning of these two symbols


∨、∧are the conjunction and disjunctive logic operations of discrete mathematics, which can be realized in one sentence in various languages. For example, using Pascal / Delphi / basic to realize the conjunction of a and B as a and B; using Pascal / Delphi / basic to realize the disjunctive of a and B as a or B; using C or C + + to realize the conjunction of a and B as a & B; using



How many of the 1000 natural numbers from 1 to 1000 do not contain the number "1"?


Let any number from 1 to 1000 be ABC, where a, B and C belong to 0,1,2,3,4,5,6,7,8,9
001 means 1
Since there is no 1 at all, there are 9 methods for a, 9 methods for B, and 9 methods for C
ABC has 9 * 9 * 9 = 729 methods
But these 729 numbers contain 000, which is 0,
So there are 729-1 = 728 numbers, totally without 1



When the bus leaves Nanjing for Wuhan at the speed of 80 ㎞, the car starts from Nanjing one hour later and catches up with the bus at the speed of 120 ㎞ / h, the time required to catch up with the bus is ()


80÷(120-80)=2h



In a triangle, it is known that the degree of ∠ A is 3 times of ∠ C, and the degree of ∠ B is 5 times of ∠ C. calculate the degree of three angles


3∠C+5∠C+∠C=180
∠C=20°
∠A=60°
∠B=100°



Uncle Wang drove from place a to place B. starting from the beginning, his speed was 1 / 9 faster than the original plan. As a result, he arrived one and a half hours earlier. When he returned, he drove 280 kilometers according to the original plan and increased his speed by 1 / 6, so he arrived at place B 2 hours earlier. How many kilometers is the distance from place a to place B?


Speed ratio: 1: (1 + 1 / 9) = 9:10
Time: 1.5 ÷ (10-9) X10 = 15 (hours)
Speed ratio: 1: (1 + 1 / 6) = 6:7
The time required for the original plan to drive 280 km:
15-2 ÷ (7-6) X7 = 1 (hour)
The distance from a to B is: 280 △ 1x15 = 4200 (km)



If a takes other values, will the size relationship between 3A + 2a and 5A change?


Always equal



The fast and slow trains leave from the two cities at the same time. The speed of the slow train is 2 / 3 of that of the fast train. The two trains meet each other six hours after they leave and continue to move forward. The speed of the fast train is faster than that of the fast train
The local train arrives at its destination () hours earlier


1÷【1/6÷(1+2/3)】×(3/2-1)
=1×1/2
=5 hours



It is known that the two focal points of the elliptic equation are F1 (- 4,0) and F2 (4,0). Under what conditions, the equation of the ellipse is x * 2 / 25 + y * 2 / 9=


A lot of them
For example, ellipse (2 √ 5, - 9 √ 5 / 5)
Or the distance between the two guide lines is 25 / 2
Or the ratio of long axis to short axis is 5:3
wait



There is a batch of cement on the construction site. In the first day, 500 tons of cement are used, 30 tons less than 1 / 6 of the total. In the second day, 1 / 3 of the total is used. How many tons of cement are used in the second day?


Total amount (500 + 30) △ 1 / 6 = 530 △ 1 / 6 = 3180 tons
3180x1 / 3 = 1060t
A: 1060 tons the next day