This commit is contained in:
Matus Tokarcik 2024-03-28 21:45:33 +01:00
parent 4c107bbe23
commit 10eac621ec
3 changed files with 56 additions and 43 deletions

View File

@ -7,17 +7,25 @@
int main(){ int main(){
char pole[100]; char pole[100];
char* a = fgets(pole, 100, stdin);
double cislo1; double cislo1;
double cislo2; double cislo2;
double vysledok; double vysledok;
char znamienko; char znamienko;
char* token; char* token;
char vysledky[50][50]; // pole pre ukladanie vysledkov
int pocet = 0;
while (1) {
char* a = fgets(pole, 100, stdin);
if (pole[0] == '\n') { //ci je riadok prazdny, ci sa stlacil enter
break;
}
token = strtok(pole, " "); //rozdelenie retazca podla medzier token = strtok(pole, " "); //rozdelenie retazca podla medzier
cislo1 = atof(token); // premena stringu na desatinne cislo a priradenie cislu1 cislo1 = atof(token); // premena stringu na desatinne cislo a priradenie cislu1
token = strtok(NULL, " "); //pokracovanie v rozdelovani retazca token = strtok(NULL, " "); //pokracovanie v rozdelovani retazca
znamienko = token[0]; // vrati ukazatel na nasledujuci token, cize znamienko znamienko = token[0]; //vrati ukazatel na nasledujuci token, cize znamienko
token = strtok(NULL, " =\n"); token = strtok(NULL, " =\n");
cislo2 = atof(token); cislo2 = atof(token);
token = strtok(NULL, " =\n"); token = strtok(NULL, " =\n");
@ -36,17 +44,25 @@ int main(){
realny = cislo1 * cislo2; realny = cislo1 * cislo2;
break; break;
case '/': case '/':
realny =cislo1 / cislo2; realny = cislo1 / cislo2;
break; break;
default: default:
printf("CHYBA\n"); printf("CHYBA\n");
return 1; return 1;
} }
if (realny == vysledok){ if (realny == vysledok){
printf ("OK\n"); strcpy(vysledky[pocet], "OK"); //kopiruje vysledok do pola vysledky
} }
else{ else{
printf ("ZLE\n"); strcpy(vysledky[pocet], "ZLE");
}
pocet++;
}
//vypis vysledkov
for (int i = 0; i < pocet; i++) {
printf("%s\n", vysledky[i]);
} }
return 0; return 0;

Binary file not shown.

View File

@ -1,18 +1,15 @@
Exception: STATUS_ACCESS_VIOLATION at rip=7FFF82234123 Exception: STATUS_ACCESS_VIOLATION at rip=000100401117
rax=00007FFF822B57E0 rbx=0000000000000000 rcx=00000007FFFFCE00 rax=0000000000000000 rbx=0000000800021389 rcx=0000000000000000
rdx=0000000000000000 rsi=000000000000000A rdi=0000000000000000 rdx=0000000100403000 rsi=0000000000000000 rdi=0000000000000000
r8 =0000000000000000 r9 =000000000000000A r10=00000007FFFFCE00 r8 =00000007FFFFCE98 r9 =0000000000000001 r10=0000000800000000
r11=000000000000002A r12=00000007FFFFCE00 r13=0000000000000000 r11=00000001004010F2 r12=0000000A00000370 r13=00000007FFFFCDF0
r14=0000000000000000 r15=00007FFF822B57E0 r14=0000000000000000 r15=0000000000000000
rbp=0000000000000000 rsp=00000007FFFFCAA0 rbp=00000007FFFFCC40 rsp=00000007FFFFCB80
program=C:\cygwin64\home\matus\a1\program.exe, pid 2084, thread main program=C:\cygwin64\home\matus\a1\program.exe, pid 2113, thread main
cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B cs=0033 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace: Stack trace:
Frame Function Args Frame Function Args
000000000000 7FFF82234123 (000000000000, 0007FFFFCC40, 000100000370, 7FFF822B57E0) cygwin1.dll+0x174123 0007FFFFCC40 000100401117 (000000000000, 000000000000, 000000000000, 000000000000) program.exe+0x1117
0007FFFFCC40 7FFF82234411 (000A00000370, 0007FFFFCDF0, 000000000000, 000800021389) cygwin1.dll+0x174411
0007FFFFCC40 7FFF82230591 (7FFF8239F0C0, 7FFF822B5800, 7FFF8239F160, A623D312A0061) cygwin1.dll+0x170591
0007FFFFCC40 00010040112D (000000000000, 000000000000, 000000000000, 000000000000) program.exe+0x112D
0007FFFFCD30 7FFF820C80A3 (000000000000, 000000000000, 000000000000, 000000000000) cygwin1.dll+0x80A3 0007FFFFCD30 7FFF820C80A3 (000000000000, 000000000000, 000000000000, 000000000000) cygwin1.dll+0x80A3
0007FFFFFFF0 7FFF820C5C86 (000000000000, 000000000000, 000000000000, 000000000000) cygwin1.dll+0x5C86 0007FFFFFFF0 7FFF820C5C86 (000000000000, 000000000000, 000000000000, 000000000000) cygwin1.dll+0x5C86
0007FFFFFFF0 7FFF820C5D34 (000000000000, 000000000000, 000000000000, 000000000000) cygwin1.dll+0x5D34 0007FFFFFFF0 7FFF820C5D34 (000000000000, 000000000000, 000000000000, 000000000000) cygwin1.dll+0x5D34