This repository was archived by the owner on Feb 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathveriExpres.cpp
More file actions
90 lines (86 loc) · 1.25 KB
/
veriExpres.cpp
File metadata and controls
90 lines (86 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
class No{
public:
char c;
No *prox;
No(char n){
c=n;
prox=NULL;
}
};
class Pilha{
public:
No *topo;
Pilha(){
topo=NULL;
}
void mostrar(){//MOSTRA A PILHA
No *atual=topo;
if(topo==NULL){
printf("A pilha esta vazia.\n");
}else{
while(atual != NULL){
printf("Nome: %c\n",atual->c);
atual=atual->prox;
}}
}
void push(char n){
No *novo = new No(n);
if(topo==NULL){
topo=novo;
}else{
novo->prox=topo;
topo=novo;
}
}
void pop(){
No *atual=topo;
topo=topo->prox;
free(atual);
}
int isVazia(Pilha *p){
return (p->topo==NULL);
}
void destroi(Pilha *p){
No *atual=topo;
if(isVazia(p)){
printf("A pilha esta vazia\n");
}else{
while(atual !=NULL){
atual=atual->prox;
pop();
}
}
}
void verifExpr(char expres[20]){
char le;
int i=0,j;
while(expres[i]!='\0'){
le=achaFlag(expres[i]);
i++;
printf("%c\n",le);
}
}
char achaFlag(char l){
char abri[3];
char fecha[3];
strcpy(abri,"{[(");
strcpy(fecha,"}])");
int i;
for(i=0;i<3;i++){
if(abri[i]==l){
return abri[i];
break;
}
}
}
};
int main(){
Pilha *p = new Pilha();
p->verifExpr("if(a==b){b=a};");
//p->mostrar();
return 0;
}