开发者

Without LIB And String file how can i write this code?

#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);
    开发者_Python百科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;
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜