If x is added or subtracted from each original data, the average value is a x and the variance is b.
If the original data is multiplied or divided by y, the average value is a multiplied or divided by y, and the variance is b multiplied or divided by (y 2).
For example, the average value of a set of data is 5.2 and the variance is 4.4. If every data in this set is subtracted by 2, a new set of data is obtained, with an average of 3.2(5.5-2) and a variance of 4.4. If each data in this set of data is multiplied by 2, a new set of data is obtained.
Computer calculation process of addition, subtraction, multiplication and division # #includevoid main(){ float a, b; char d; Printf ("Please enter two numbers A and B:"); Scanf("%f,% f "& & b); Printf ("Please enter operator number d"); scanf("%c ",d); switch(d) { case'+':printf("%f\n ",a+b); Break; case'-':printf("%f\n ",a-b); Break; Case' *': Print.
After all five nines are added, subtracted, multiplied and divided = 100, I want to work out the process 9*9+9+9/.9= 100.
Enter 4 numbers, add, subtract, multiply and divide to calculate 24, and the calculation process will be displayed, prompting the success message # include "stdlib.h".
# contains "stdio.h"
#include "string.h" typedef structure D_NODE
{
Int data;
Structure D_NODE *left, * right
} NODE24
NODE24 head; int res = 24int maketree(int *src,int *i,NODE24 *p)
{
int d = src[* I];
(* I)++;
Switch (d)
{
Case "+":
Case'-':
Case' *':
Case "/":
p->; Left = new node 24;
p->; Right = new node 24;
p->; Data = d;;
Maketree(src, I, p- > left);
Maketree(src, I, p- > pair);
Break;
Default value:
p->; Data = d;;
p->; left = NULL
p->; Right = empty;
}
Returns 0;
}int cmaketree(NODE24 *p)
{
int c;
c = getchar();
putchar(c);
Switch (c)
{
Case "+":
Case'-':
Case' *':
Case "/":
p->; Left = new node 24;
p->; Right = new node 24;
p->; Data = c;;
cmaketree(p-& gt; Left);
cmaketree(p-& gt; Right);
Break;
Default value:
p->; Data = c-' 0 ';;
p->; left = NULL
p->; Right = empty;
}
Returns 0;
}int work(struct D_NODE *d)
{
int RES = 0;
if(d-& gt; left = = NULL & amp& ampd-& gt; right==NULL)
RES = d-& gt; Data;
other
{
int a,b;
A = work (d->; Left);
B = work (d-> Right);
Switch (d->; Data)
{
Case "+":
RES = a+b; Work (d->; Left)+Work (D-> Right);
Break;
Case'-':
RES = a-b; Work (d->; Left)-Work (D-> Right);
Break;
Case' *':
RES = a * b; Work (d->; Left) * work (d->; Right);
Break;
Case "/":
If (b! =0)
res=(a%b==0)? A/B:-79;
other
RES =-79;
RES = work(d-& gt; Right)? Work (d->; Left)/Work (D-> Right):-79;
Break;
}
}
Return to res
}int destroy(struct D_NODE *d)
{
if(d-& gt; left = = NULL & amp& ampd-& gt; right==NULL)
Delete d;
other
{
Destroy (d->; Left);
d-& gt; left = NULL
Destroy (d->; Right);
d-& gt; Right = empty;
If (d! = & head)
Delete d;
}
Returns 0;
}int show(struct D_NODE *d)
{
if(d-& gt; left = = NULL & amp& ampd-& gt; right==NULL)
printf("%d ",d-& gt; Data);
other
{
printf("(");
Display (d->; Left);
printf("%c ",d-& gt; Data);
Display (d->; Right);
printf(")");
}
Returns 0;
}/* int input ()
{
int buf[30]={'* ','+',' 2 ',' 4 ','+',' 2 ',' 3'},idx = 0;
Spanning tree (buf&; idx & amp; Head); int buf[20],idx = 0;
Printf ("\ nPlease enter:");
for(idx = 0; idx & lt20; idx++)
{
buf[idx]= getch();
printf("%c ",buf[idx]);
}
idx = 0;
Spanning tree (buf&; idx & amp; Head);
Returns 0;
} */#define test(p 1,p2,p3,p4,p5,p6,p7) {exp[0]=(p 1),exp[ 1]=(p2),\ & ltbr & gtexp[2]=(p3),exp[3]=(p4),exp[4]=(p5),exp[5]=(p6),exp[6]=(p7); \ & ltbr & gtidx = 0; \ & ltbr & gt spanning tree (exp & amp; idx & amp; Head); \ & ltbr & gt If (work (& head) = = res) \ < Br>{ \ & ltbr & gt found++; Printf("%5d: ",found); Display (& header); \ & ltbr & gt If (! (Found% 3)) printf ("\ n"); \ & ltbr & gt} \
Destroy (& head); \
} printf("%d,%d,%d,%d,%d,%d,%d,%d\n ",p 1,p2,p3,p4,p5,p6,p7); \int test24()
{
int num[4],opc[4]={'+','-',' * ',/'},exp[20];
int i 1,i2,i3,i4,ic 1,ic2,ic3,idx,found = 0; Charprompt [] = "Blackjack analysis \ n ";;
Printf("%s ",prompt);
for(I 1 = 0; I 1 & lt; 4; i 1++)
{
Printf ("Please enter the number %d:", I1+1);
scanf("%d ",num+I 1);
num[I 1]= num[I 1]% 13+ 1;
}
Printf ("\ nYou have entered: %d, %d, %d, %d! \n ",num[0],num[ 1],num[2],num[3]);
Printf ("\ nPlease enter the result value to be calculated, (of course, enter 24 at 24 o'clock! ):");
scanf("%d ",& ampRES);
Printf ("Good! Press any key to start! \ n ");
getchar();
for(I 1 = 0; I 1 & lt; 4; i 1++)
for(I2 = 0; i2 & lt4; i2++)
If (i2! =i 1)
for(i3 = 0; i3 & lt4; i3++)
If (i3! = I 1 & amp; & ampi3! =i2)
for(i4 = 0; i4 & lt4; i4++)
If (i4! = I 1 & amp; & ampi4! = i2 & amp& ampi4! =i3)
for(IC 1 = 0; IC 1 & lt; 4; ic 1++)
for(ic2 = 0; ic2 & lt4; ic2++)
for(ic3 = 0; ic3 & lt4; ic3++)
{
test(opc[ic 1],opc[ic2],opc[ic3],num[i 1],num[i2],num[i3],num[i4]);
test(opc[ic 1],opc[ic2],num[i 1],opc[ic3],num[i2],num[i3],num[i4]);
test(opc[ic 1],opc[ic2],num[i 1],num[i2],opc[ic3],num[i3],num[i4]);
test(opc[ic 1],num[i 1],opc[ic2],opc[ic3],num[i2],num[i3],num[i4]);
test(opc[ic 1],num[i 1],opc[ic2],num[i2],opc[ic3],num[i3],num[i4]);
}
Printf("\n*** found %d correct calculation methods! (Sorry, I didn't handle the exchange rate * _ *) \ n ",found);
Returns 0;
}int main()
{
fflush(stdin);
input();
cmaketree(& amp; Head);
printf("\n=%d\n ",work(& amp; Head));
test 24();
Returns 0;
}
The elementary arithmetic calculation process of addition, subtraction, multiplication and division of fractions in an equation (with answers) (1), if it only contains the same level of operations, it is calculated from left to right.
(2) If an expression contains two-level operations, the second-level operation is calculated first, and then the first-level operation is calculated.
(3) In an equation, if there are parentheses, count the parentheses first and then the parentheses.
C Enter four numbers, and through addition, subtraction, multiplication and division calculation 24, the calculation process will be displayed, and the success message will be prompted. My solution is to decompose this problem into two sub-problems. First, I found a non-repeating full array of four numbers and put them into an array. Then, I listed all four unordered operations from beginning to end. Note that division is special. I use x/y to represent x divided by y, and x|y represents y of x. Note that if you get -24 by exhaustive solution, you only need to change the order of subtraction. The code is as follows.
/***********************************************************************************/
# include & ltstdio.h & gt
# include & ltstdlib.h & gt
# include & ltmath.h & gt
# include & ltstring.h & gt
int index[4]={0, 1,2,3 }; Used to generate subscription collection.
int sub[4]; Only used in p ()
float f[4]={8.0f,3.0f,3.0f,8.0f }; 24-point number
float fs[24][4]; All possible permutations of f
Floating tmp [4]; Used for buf
int g _ number = 0; number of permutations
float RES[4];
char op[3];
Void p(int idx){ Find a completely permuted function.
if(idx==4){
for(int I = 0; I<4; ++ I){ tmp[I]= f[sub[I]]; }
for(int g = 0; g & ltg _ number++g){if(memcmp(fs[g],tmp,sizeof(float)* 4)= = 0)return; }
for(int I = 0; I<4; ++ I){ fs[g _ number][I]= f[sub[I]]; }
g _ number++;
Return;
}
for(int I = 0; I<4; ++ I){ Conduct subscription collection.
bool dupflag = false
for(int j = 0; j & ltidx++ j){ if(sub[j]= = I)dup flag = true; }
If(dupflag==true) continues;
sub[idx]= index[I];
p(idx+ 1);
}
}
Void solve(int L){ For an arrangement, recursively find the results of all four operations, and exit if found.
if(L==3){
if(fabs(fabs(RES[L])-24.0 f)& lt; 0.0 1f){
Printf ("found solution, RES=%f, ((%d%c%d)%c%d)%c%d\n", RES[L],
(int)f[0],op[0],
(int)f[ 1],op[ 1],
(int)f[2],op[2],
(int)f[3]);
Exit (0);
}
Return;
}
for(int j = 0; j & lt5; Judgment of ++j){j operator
if(j = = 0){ RES[L+ 1]= RES[L]+tmp[L+ 1]; op[L]= '+'; Solve (l+1); }
if(j = = 1){ RES[L+ 1]= RES[L]-tmp[L+ 1]; op[L]= '-'; Solve (l+1); }
if(j = = 2){ RES[L+ 1]= RES[L]* tmp[L+ 1]; op[L]= ' * '; Solve (l+1); }
if(j = = 3 & amp; & amptmp[L+ 1]! =0)
{ RES[L+ 1]= RES[L]/tmp[L+ 1]; op[L]= '/'; Solve (l+1); }
if(j = = 4 & amp; & ampRES[L+ 1]! =0)
{ RES[L+ 1]= tmp[L+ 1]/RES[L]; op[L]= ' | '; Solve (l+1); }
}
}
Int main(int argc, char * argv[]){ 0 should be avoided.
f[0]= atoi(argv[ 1]);
f[ 1]= atoi(argv[2]);
f[2]= atoi(argv[3]);
f[3]= atoi(argv[4]);
p(0);
for(int I = 0; I<g _ number++i){
memcpy(tmp,fs[i],sizeof(float)* 4);
RES[0]= tmp[0];
for(int t = 0; t & lt4; ++t){ printf("%d,",(int)tmp[t]); }
printf(" \ n ");
Solve (0);
}
Printf ("Solution not found: (\ n");
Returns 0;
}
-Compile and execute, and the parameters during execution are 4 digits.
g ++ p . CPP & amp; & amp。 /a.out 1 5 5
1,5,5,5,
Find the solution, RES=-24.000000, ((1/5)-5)*5.
g ++ p . CPP & amp; & amp。 /a.out 8 3 3 8
8,3,3,8,
Found the solution, RES=-24.000006, ((8/3)-3)|8.
The above solution is written like this.
eight
- = 24
3-(8/3)
In order to simplify the main program, the input check is omitted, and the landlord can add it himself.
Kneel down and enter four numbers to calculate 24 through addition, subtraction, multiplication and division, and display the C language program # include.
Double fun (double a 1, double a2, int b)
{switch (b)
{case 0: return (a1+a2);
Case 1: return (a1-a2);
Case 2: Return (A1* A2);
Situation 3: Return (A1/A2);
}
}
void main()
{int i,j,k,l,n,m,r,save[4];
double num[4]={ 1, 1, 1, 1},tem 1,tem2,tem3,ABC = 1 1 1;
Character symbol [5] = "+-*/";
Printf ("Enter 4 digits:");
for(I = 0; I<4; i++)
{scanf("%lf ",num+I); save[I]= num[I]; }
for(I = 0; I<4; i++)
for(j = 0; j & lt4; j++)
If (j! =i)
{ for(k = 0; k & lt4; k++)
If (k! = i & amp& ampk! =j)
{ for(l = 0; l & lt4; l++)
If (l! = I & me! = j & me! =k)
{ for(n = 0; n & lt4; n++)
for(m = 0; m & lt4; m++)
for(r = 0; r & lt4; r++)
{tem 1=fun(num[i],num[j],n);
tem2=fun(tem 1,num[k],m);
tem3=fun(tem2,num[l],r);
if(tem 3 = = 24.0)printf(" {(% d % c % d)% c % d } % c % d = 24 \ n ",save[i],sign[n],save[j],sign[m],save[k],sign[r],save[l]);
else if(te m3 = =-24.0)printf(" { % d % c(% d % c % d)} % c % d = 24 \ n ",save[k],sign[m],save[i],sign[n],save[j],sign[r],save[l]);
else if(te m3 = = 1.0/24.0)printf(" % d % c {(% d % c % d)% c % d } = 24 \ n ",save[l],sign[r],save[i],sign[n],save[j],sign[m],save[k]);
else if(te m3 = =- 1.0/24.0)printf(" % d % c { % d % c(% d % c % d)} = 24 \ n ",save[l],sign[r],save[k],sign[n],save[i],sign[m],save[j]);
other
{tem 1=fun(num[i],num[j],n);
tem2=fun(num[k],num[l],r);
tem3=fun(tem 1,tem2,m);
if(te m3 = = 24.0)printf("(% d % c % d)% c(% d % c % d)= 24 \ n ",save[i],sign[n],save[j],sign[m],save[k],sign[r],save[l]);
}
}
}
}
}
}
Add, subtract, multiply and divide by 3, 4, -6, 10, so that the result is equal to 24. Please explain the calculation process and method. Thank you for your help! 3×[4+ 10+(-6)]=24
3×( 10-4)-(-6)=24
10-4-3×(-6)=24
4- 10×(-6)÷3=24
There are two ways to calculate the degree of an angle: angle system and arc system. You should ask the angle system.
The angle system is hexadecimal, and the units from the largest to the smallest are degrees, minutes and seconds.
Addition and subtraction, small unit addition and subtraction. If it is not enough, borrow one unit's 1, which is equivalent to 60. If it exceeds 60, subtract 60 from the previous unit and enter 1.
Multiplication, each unit is multiplied by itself, and the first bit of more than 60 is less than 60 until the number before minutes and seconds.
Division, for simplicity, converts all angles into seconds, then divides them, and then converts them into degrees, minutes and seconds according to the principle that 60 becomes 1. What is given here is a general method. If the given formula is special, as long as there is no endless division, you can divide every minute by one minute.
Calculation of addition, subtraction, multiplication and division formula 1. 3/7 × 49/9-4/3
2.8/9 × 15/36 + 1/27
3. 12× 5/6 – 2/9 ×3
4.8× 5/4 + 1/4
5.6÷ 3/8 – 3/8 ÷6
6.4/7 × 5/9 + 3/7 × 5/9
7.5/2 -( 3/2 + 4/5 )
8.7/8 + ( 1/8 + 1/9 )
9.9 × 5/6 + 5/6
10.3/4 × 8/9 - 1/3