Aktualizovat du3/program.c
This commit is contained in:
parent
f5355bd4dd
commit
623783ebc4
@ -6,6 +6,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#define SIZE 128
|
||||
#define TEMPBUFFERSIZE 32
|
||||
|
||||
//kontrola, ze ci vycitane informacie su aritmeticky spravne
|
||||
//VRACIA: int: -1 (CHYBA), 0 (False), 1 (True)
|
||||
@ -61,11 +62,12 @@ int main()
|
||||
{
|
||||
bool isLineInvalid = false;
|
||||
//docasne 'char' premeny
|
||||
char num1Temp[10], num2Temp[10], resultTemp[10];
|
||||
char num1Temp[TEMPBUFFERSIZE], num2Temp[TEMPBUFFERSIZE], resultTemp[TEMPBUFFERSIZE];
|
||||
num1Temp[0] = '\0';
|
||||
num2Temp[0] = '\0';
|
||||
resultTemp[0] = '\0';
|
||||
bool foundEqualSign = false;
|
||||
bool isNotMinus;
|
||||
|
||||
char op1 = 'N'; //N = 'None/NIC'
|
||||
|
||||
@ -96,6 +98,21 @@ int main()
|
||||
}
|
||||
else if (strBuffer[i] == '=')
|
||||
{
|
||||
//kontrola - zistenie, ze ci znak '-' symbolizuje zapornu hodnotu (-456) alebo arit. operaciu minus
|
||||
//zistujeme to na zaklade toho, kde sme v riadku, ak na zaciatku
|
||||
if (op1 == 'N' && strlen(num1Temp) == 0)
|
||||
{
|
||||
isNotMinus = true;
|
||||
}
|
||||
//
|
||||
else if (op1 != 'N' && !foundEqualSign && strlen(num2Temp) == 0)
|
||||
{
|
||||
isNotMinus;
|
||||
}
|
||||
else if (foundEqualSign && strlen(resultTemp) == 0)
|
||||
{
|
||||
isNotMinus;
|
||||
}
|
||||
foundEqualSign = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user