#include<stdio.h>
#include<malloc.h>#include<stdlib.h>typedef struct{ int *element; int length; int listsize;}SeqList; int InitSeqList(SeqList &S){ S.element=(int *)malloc(sizeof(int)*100); S.length=0; S.listsize=100; return 0;} ///int insert(SeqList &S,int x,int i){ if(i>S.listsize) printf(" 插入有误!!\n"); if(S.listsize==i)//(int)S.length { S.element=(int *)realloc(S.element,(S.listsize+12)*sizeof(int)); S.listsize=S.listsize+12; S.element[i]=x; S.length++; } else { if(i==S.length) { S.element[S.length]=x; S.length++; } else { for(int k=S.length;k>=i;k--) { S.element[k+1]=S.element[k]; } S.element[k]=x; S.length++; } } return 1;} void display(SeqList &S,int i){ if(i>S.length) { printf("display is eror!"); return ; } printf(" %d ",S.element[i]);} int DuiC(SeqList &S){ int i; int j=0; for(i=0;i<=S.length/2;i++) { if(S.element[i]!=S.element[S.length-i-1]) return 0; } return 1;}///void Paixun(SeqList &S){ int i,j=0,k=0,t,p; for(i=0;i<S.length-1;i++) { if(S.element[i]%2==0) { for(p=i+1;p<S.length;p++) { if(S.element[p]%2==1) { j=p; t=S.element[j]; for(k=j-1;k>=i;k--) { S.element[k+1]=S.element[k]; } S.element[i]=t; break; } } } }} void Free(SeqList &S){ free(S.element);}/
int main(){ SeqList s; InitSeqList(s); int k=rand(); for(int i=0;i<20;i++) { k=rand(); insert(s,k,i); } //insert(s,200,100); for(i=0;i<20;i++) { display(s,i); } if(!DuiC(s)) printf("\n it is not 对称!!\n"); else printf("\n it is 对称!!\n"); Paixun(s); for(i=0;i<20;i++) { display(s,i); } printf("\n"); return 0;}