This commit is contained in:
Damián Korpesio 2021-11-28 18:00:09 +01:00
parent 3145d42f07
commit 29351306ac

View File

@ -17,18 +17,13 @@ int main(){
n = strlen(r); n = strlen(r);
//printf("%ld", n); //printf("%ld", n);
while(r[i] != '\n'){ while(r[i] != '\n'){
//puts("1");
if (r[0] != '{' || r[0] != '(' || r[0] != '[' || r[0] != '<') { if (r[0] != '{' || r[0] != '(' || r[0] != '[' || r[0] != '<') {
i = n - 2; //i = n - 2;
hej = 1; hej = 1;
//puts("halo"); //puts("halo");
} }
if (r[0] == '}' || r[n - 2] == '}'){
hej = 3;
printf("Read: %s", r);
printf("Unexpected closing bracket } in %d\n", i);
i = n - 2;
}
if (r[i] == '{') { if (r[i] == '{') {
hodnota = 1; hodnota = 1;
i++; i++;
@ -48,18 +43,18 @@ int main(){
//printf("hodnota: %d\n", hodnota); //printf("hodnota: %d\n", hodnota);
if (hodnota == 1){ if (hodnota == 1){
hodnota = 0; //hodnota = 0;
for (a = p; a<n; a++){ for (a = p; a<n; a++){
printf("%d", a); //printf("%d", a);
if (r[a] == '}') { if (r[a] == '}') {
puts("joj"); //puts("joj");
hej = 1; hej = 1;
//r[a] = 'a'; //r[a] = 'a';
p = a; p = a;
a = n; a = n;
} }
else if (r[a] == ')' || r[a] == ']' || r[a] == '>'){ else if (r[a] == ')' || r[a] == ']' || r[a] == '>'){
puts("nie"); //puts("nie");
hej = 0; hej = 0;
a = n; a = n;
i = n - 1; i = n - 1;
@ -68,16 +63,17 @@ int main(){
} }
} }
else if (hodnota == 2){ else if (hodnota == 2){
hodnota = 0; //hodnota = 0;
for (a = p; a>n; a++){ for (a = p; a>n; a++){
if (r[a] == ')') { if (r[a] == ')') {
//puts("hod 2");
hej = 1; hej = 1;
//r[a] = 'a'; //r[a] = 'a';
p = a; p = a;
a = n; a = n;
} }
else if (r[a] == '}' || r[a] == ']' || r[a] == '>'){ else if (r[a] == '}' || r[a] == ']' || r[a] == '>'){
puts("nasiel"); //puts("nasiel");
hej = 0; hej = 0;
a = n; a = n;
i = n - 1; i = n - 1;
@ -85,11 +81,12 @@ int main(){
} }
} }
else if (hodnota == 3) { else if (hodnota == 3) {
hodnota = 0; //hodnota = 0;
for (a = p; a < n; a++) { for (a = p; a < n; a++) {
//puts("neidem"); //puts("neidem");
if (r[a] == ']') { if (r[a] == ']') {
//puts("nasiel som"); //puts("nasiel som");
puts("hod 3");
hej = 1; hej = 1;
//r[a] = 'a'; //r[a] = 'a';
p = a; p = a;
@ -105,16 +102,17 @@ int main(){
} }
} }
else if (hodnota == 4){ else if (hodnota == 4){
hodnota = 0; //hodnota = 0;
for (a = p; a>n; a++){ for (a = p; a>n; a++){
if (r[a] == '>') { if (r[a] == '>') {
//puts("hod 4");
hej = 1; hej = 1;
//r[a] = 'a'; //r[a] = 'a';
p = a; p = a;
a = n; a = n;
} }
else if (r[a] == '}' || r[a] == ']' || r[a] == ')'){ else if (r[a] == '}' || r[a] == ']' || r[a] == ')'){
puts("nasiel"); //puts("nasiel");
hej = 0; hej = 0;
a = n; a = n;
i = n - 1; i = n - 1;
@ -122,9 +120,23 @@ int main(){
} }
} }
else{ if (hodnota == 0){
if (r[i] == '}' || r[i] == ')' || r[i] == ']' || r[i] == '>') {
hej = 3;
//puts("ahoj");
printf("Read: %s", r);
if (r[i] == '}'){printf("Unexpected closing bracket } in %d\n", i+1);}
else if (r[i] == ')'){printf("Unexpected closing bracket ) in %d\n", i+1);}
else if (r[i] == ']'){printf("Unexpected closing bracket ] in %d\n", i+1);}
else if (r[i] == '>'){printf("Unexpected closing bracket > in %d\n", i+1);}
i = n - 2;
}
i++; i++;
} }
//else{
// i++;
//}
} }
if (hej == 1){ if (hej == 1){
printf("Read: %s", r); printf("Read: %s", r);