Without LIB And String file how can i write this code??
Posted
by muhammadlodhi
on Stack Overflow
See other posts from Stack Overflow
or by muhammadlodhi
Published on 2010-04-16T14:35:27Z
Indexed on
2010/04/16
14:43 UTC
Read the original article
Hit count: 149
Filed under:
c
#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;
}
© Stack Overflow or respective owner