结果是NO EXIST!
???
#include<stdio.h> #include<stdlib.h> #define MAXNUM 100 #define FALSE 0 #define TRUE 1 #define SPECIAL 2147483647 typedef int DataType; struct SeqList { DataType element[MAXNUM]; int n; }; typedef struct SeqList *PSeqList; PSeqList creatNullList_seq(void); PSeqList insert_seq(PSeqList palist,DataType x,int p); DataType retrieve_seq(PSeqList palist,int p); int isNullList_seq(PSeqList palist); main() { int w; PSeqList palist ; palist=(PSeqList)malloc(sizeof(struct SeqList)); palist=insert_seq(palist,1,1); w=retrieve_seq(palist,1); printf("%d ",w); getch(); } PSeqList creatNullList_seq(void) { PSeqList palist; palist=(PSeqList)malloc(sizeof(struct SeqList)); if(palist!=NULL) { palist->n=0; return palist; } else { printf("Out of space"); return (NULL); } } PSeqList insert_seq(PSeqList palist,DataType x,int p) { int q; if(palist->n==MAXNUM) { printf("Overflow!\n"); return (FALSE); } if(p<0||p>(palist->n)) { printf("No exist!\n"); return (FALSE); } else { for (q=(palist->n);q>p;q--) { palist->element[q+1]=palist->element[q]; } palist->element[p]=x; palist->n=palist->n+1; } return(palist); } int retrieve_seq(PSeqList palist,int p) { if(p<0||p>palist->n) { printf("No exist!\n"); return (SPECIAL); } else return (palist->element[p-1]); }