#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct Node;
typedef struct Node * PtrToNode;
struct Node
{
char element;
PtrToNode Next;
};
PtrToNode MakeEmpty(PtrToNode L)
{
L= new(Node);
L->Next=NULL;
return L;
}
void Push(PtrToNode L,char x)
{
PtrToNode S;
S= new(Node);
S->element=x;
S->Next=L->Next;
L->Next=S;
}
char Pop(PtrToNode L)
{
PtrToNode P;
P=L->Next;
char x=P->element;
L->Next=P->Next;
free(P);
return x;
}
int main()
{
PtrToNode L;
L= MakeEmpty(NULL);
char Input[1000];
int i;
printf("please enter your equation:");
scanf("%s",Input);
for (i = 0;i<strlen(Input);i++)
{
if (Input[i]=='(')
{
Push(L,Input[i]);
}
if (Input[i]==')')
{
if (L->Next==NULL)
{
printf("incorrect");
return 0;
}
else
Pop(L);
}
}
if (L->Next==NULL)
printf("correct");
else
printf("incorrect");
getch();
return 0;
}
views:
27answers:
1
+1
A:
You'd have to find alternative libraries for string and memory handling, or code them up yourself. Considering all those libs, save for conio, are standard, I can't find a purpose for omitting them.
Kyte
2010-04-16 14:38:59
None of them is required in a "freestanding implementation" (e.g., often used on the smaller embedded systems).
Jerry Coffin
2010-04-16 14:42:41
ok but in this program we use --> what is working of this arrow?? u can see some lines there? initially out tutor dunt teach this what is this here ????
muhammadlodhi
2010-04-16 14:42:54