Thread: why comu up error about this codes??

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    8

    why comu up error about this codes??

    this file is some large,but i hope you can read it , and tell me ,wicth can be changed. thanks in advance.

    Code:
    #define LIST_INIT_SIZE 10
    #define LISTINCREMENT  1
    #define OK		1
    #define ERROR		0
    typedef int 	ElemType
    typedef int 	Status
    
    typedef struct{
    	ElemType *elem;
    	int  	 length;
    	int	 listsize;
    
    }SqList;
    
    int InitList_Sq(SqList &L){
    
    	L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
    	if(! L.elem) return ERROR;
    	L.length=0;
    	L.listsize=LIST_INIT_SIZE;
    	return OK;
    }
    
    int ListInsert_Sq(SqList &L,int i,ElemType e){
    
    	if(i<1||i>L.length+1) return ERROR;
    	if(L.length>=L.listsize)
    	   newbase=(ElemType *)realloc((L.listsize+LISTINCREMENT)*sizeof(ElemType));
    	if(! l.elem) return ERROR;
    	L.elem=base;
    	L.listsize+=LISTINCREMENT;
    	q=&L.elem[i-1];
    	for(p=&(L.elem[L.length-1]);p>=q;p--) *(P+1)=*p;
    	*q=e;
    	L.length++;
    	return OK;
    }
    
    int ListDelete_Sq(SqList &L,int i,Elemtype e){
    
    	if(i<1||i>L.length+1) return ERROR;
    	q=&L.elem[i-1];
    	e=*q;
    	for(q;q<=(p=&L.elem[L.length-1]);++q) *q=*(q+1);
    	--L.length;
    	return OK;
    }
    
    int LocateElem_sq(sqList L,Elemtype Status (* compare)(ElemType,ElemType)){
    
    	while(i<L.length&&!(* compare)(*p++,e)) ++i;
    	if(i<=L.length) return i;
    	else return ERROR;
    
    }
    
    void MergeList_Sq(SqList La,SqList Lb,SqList &Lc){
    
    	pa=La.elem;	pb=Lb.elem;
    	pa_last=La.elem+La.length-1;
    	pb_last=Lb.elem+Lb.length-1;
    	Lc.elem=(ElemType *)malloc((La.listsize+Lb.listsize)*(sizeof(ElemType)));
    	pc=Lc.elem
    	if(! Lc.elem) return ERROR;
    	Lc.listsize=La.listsize+Lb.listsize;
    	while(pa<=pa_last&&pb<=pb_last)){
    		if(*pa<*pb)  *pc=*pa; ++pa;
    		else *pc=*pb; ++pb;
    		}
    	while(pa<pa_last) *pc=*pa;
    	while(pb<pb-last) *pc=*pb;
    	return OK;
    
    }
    
    void List_OutPut(SqList &L){
    
    	for(i=0,i<L.length;i++) printf("ElemType",l.elem[i]);
    }
    
    main()
    {
    	SqList *L;
    	char   cmd;
    	int i,t;
    	clscr();
    	printf("I......Insert\n");
    	printf("D......Delete\n");
    	printf("Q......Quit\n");
    	do{
    		do{
    		   cmd=getchar();
    		   }while(cmd!="d"||cmd!="q"||cmd!="i");
    	switch(cmd){
    		    case "i":scanf(&e);
    			     scanf(&i);
    			     ListInsert_Sq(L,i,e);
    			     List_OutPut(L);
    			     break;
    		    case "d":scanf(&e);
    			     scanf(&i);
    			     ListDelete_Sq(L,i,e);
    			     List_OutPut(L);
    			     break;
    	   }while(cmd!="q");
    
    
    }
    

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    24
    Maby a stupid question,
    but is this all?
    if yes.

    #include <stdio.h> isnt there place it above the #define's

    hope i helped

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    8

    thanks

    thans for your two help.because i learnt it is not well ,so i ofen question .let me try in computer later

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. codes
    By IfYouSaySo in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 11-18-2005, 03:09 PM
  2. action replay codes
    By c++.prog.newbie in forum Game Programming
    Replies: 2
    Last Post: 02-28-2004, 08:47 AM
  3. anyone have linked-list sample codes?
    By ling in forum C++ Programming
    Replies: 3
    Last Post: 07-03-2002, 02:24 PM