Изменил(а) на 'cv3/program.c'
This commit is contained in:
parent
3034a490df
commit
71bc6751f4
@ -33,25 +33,25 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){
|
|||||||
|
|
||||||
switch(buffer[currentlyInBuffer][0]){
|
switch(buffer[currentlyInBuffer][0]){
|
||||||
case '+':
|
case '+':
|
||||||
temporaryDecimal = round((atof(buffer[currentlyInBuffer-1]) + atof(buffer[currentlyInBuffer-2]))*100)/100;
|
temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) + atof(buffer[currentlyInBuffer-1]))*100)/100;
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
temporaryDecimal = round((atof(buffer[currentlyInBuffer-1]) - atof(buffer[currentlyInBuffer-2]))*100)/100;
|
temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) - atof(buffer[currentlyInBuffer-1]))*100)/100;
|
||||||
break;
|
break;
|
||||||
case '*':
|
case '*':
|
||||||
temporaryDecimal = round((atof(buffer[currentlyInBuffer-1]) * atof(buffer[currentlyInBuffer-2]))*100)/100;
|
temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) * atof(buffer[currentlyInBuffer-1]))*100)/100;
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if(atof(buffer[currentlyInBuffer-2]) == 0.0)
|
if(atof(buffer[currentlyInBuffer-1]) == 0.0)
|
||||||
printf("division by zero\n");
|
printf("division by zero\n");
|
||||||
else
|
else
|
||||||
temporaryDecimal = round((atof(buffer[currentlyInBuffer-1]) / atof(buffer[currentlyInBuffer-2]))*100)/100;
|
temporaryDecimal = round((atof(buffer[currentlyInBuffer-2]) / atof(buffer[currentlyInBuffer-1]))*100)/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = currentlyInBuffer-3; currentlyInBuffer > i; currentlyInBuffer--)
|
for(int i = currentlyInBuffer-3; currentlyInBuffer > i; currentlyInBuffer--)
|
||||||
memset(buffer[currentlyInBuffer], SIZE, '\0');
|
memset(buffer[currentlyInBuffer], SIZE, '\0');
|
||||||
|
|
||||||
gcvt(temporaryDecimal, 10, buffer[currentlyInBuffer]);
|
gcvt(temporaryDecimal, 10, buffer[currentlyInBuffer++]);
|
||||||
|
|
||||||
for(int i = 0; i <= currentlyInBuffer; i++){
|
for(int i = 0; i <= currentlyInBuffer; i++){
|
||||||
if(i == currentlyInBuffer)
|
if(i == currentlyInBuffer)
|
||||||
@ -81,4 +81,3 @@ bool calculatorLogic(char buffer[SIZE][SIZE]){
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user