%%---------------------------------------------------------------- %% All the programs as listed in the book in the Appendix --- %%---------------------------------------------------------------- #include #define MAXSIZE 13 void main() { int SetPartition[MAXSIZE],n=4; int i,max,j=n; while(j>0) { for(i=1;i<=n;i++) SetPartition[i]=1; printf("\n"); max=0; for(i=1;imax) max=SetPartition[i]; while(SetPartition[j]==max+1) { j--; max=0; for(i=1;imax) max=SetPartition[i]; } if (j>0) { SetPartition[j]++; for(i=j+1;i<=n;i++) SetPartition[i]=1; j=n; } } } %------------------------------------------------------------------------ #include #define MAXSIZE 13 int SetPartition[MAXSIZE],n=4; void main() { int i,j,p,pos,kp,tt; int s[MAXSIZE][MAXSIZE],ls[MAXSIZE], fs[MAXSIZE][MAXSIZE],ns[MAXSIZE]; SetPartition[1]=1; s[1][1]=1; ls[1]=1; fs[1][1]=1; ns[1]=1; for(i=2;i<=n;i++) { SetPartition[i]=1; s[i][1]=1; s[i][2]=2; ls[i]=2; fs[1][1]=1; fs[i][2]=0; ns[i]=1; } pos=2; while(pos>1) { for(i=1;i<=n;i++) SetPartition[i]=1; printf("\n"); pos=n; while(ns[pos]==ls[pos]) pos--; if (pos>0) { p=0; for(i=1;i<=pos-1;i++) if(SetPartition[i]>p) p=SetPartition[i]; kp=ls[pos]; while(fs[pos][kp]==1) kp--; ns[pos]++; SetPartition[pos]=s[pos][kp]; fs[pos][kp]=1; for(i=pos;i<=n-1;i++) { if(p1) fs[i+1][SetPartition[i+1]-1]=1; else fs[i+1][p+1]=1; } } } } %------------------------------------------------------------------------------- #include #define MAXSIZE 50 int n,SetPartition[MAXSIZE],pattern[MAXSIZE],tau[MAXSIZE],lentau; long num1=0; int order(int a,int b) { if (a==b) return 0; else if(a>b) return 1; else return -1; } int test(int k,int *p1,int *p2) { int i; for (i=0;imvv) mvv=pattern[i1]; i3=0; for(i1=1;i1<=mvv;i1++) { for(i2=0;i2vv) vv=pattern[i]; for(j=1;j<=vv+1;j++) { pattern[l]=j; builtsp(l+1); } } } int main() { int i,j,s=0; printf("Give me the length (3-7) of the pattern :"); scanf("%d",&lentau); printf("Write a pattern as sequence (example 3 1 2) :"); for(i=0;i #define MAXSIZE 50 int n,word[MAXSIZE],tau[MAXSIZE],lentau; long num1=0; int order(int a,int b) { if (a==b) return 0; else if(a>b) return 1; else return -1; } int test(int k,int *p1,int *p2) { int i; for (i=0;ivv) vv=word[i]; for(j=1;j<=vv+1;j++) { pword[l]=j; builsp(l+1); } } } int main() { int i,j,s=0; printf("Give me the length (3-7) of the pattern :"); scanf("%d",&lentau); printf("Write a pattern as sequence (example 3 1 2) :"); for(i=0;i #define MAXSIZE 50 int n,word[MAXSIZE],p[MAXSIZE]; int nlet[MAXSIZE]; long num1=0; int listp[1000][7],nlistp=0; FILE *fout; int order(int a,int b) { if (a==b) return 0; else if(a>b) return 1; else return -1; } int test(int k,int *p1,int *p2) { int i; for (i=0;ivv) vv=word[i]; for(j=1;j<=vv+1;j++) { nlet[j]++; word[l]=j; builtwsp(l+1,lenp); nlet[j]--; } } } void builtpatterns(int l,int lenp) { int i,j,v; if (l==lenp) { for(i=0;iv) v=p[i]; for(j=1;j<=(v+1);j++) { p[l]=j; builtpatterns(l+1,lenp); } } } int main() { int lenp=7; fout=fopen("fpart7.txt","w"); builtpatterns(0,lenp); int i,j,i1,j1,j2,ii,sw; int ncc=0; for(i1=0;i1 #define MAXSIZE 50 int n,NK; int word[MAXSIZE],p[MAXSIZE]; long num1=0; int listp[100000][10],nlistp=0,nl=0; int nlet[MAXSIZE]; FILE *fout; /*file contains the output*/ int order(int a,int b) { if (a==b) return 0; else if(a>b) return 1; else return -1; } int test(int k,int *p1,int *p2) { int i; for (i=0;i1) return 0;} } } } if (acc==1) return 1; else return 0; } int c1patterns4() { int curword[4]; int i1,i2,i3,i4,acc=0; for(i4=0;i41) return 0;} } } } } if(acc==1) return 1; else return 0; } int c1patterns5() { int curword[5]; int i1,i2,i3,i4,i5,acc=0; for(i5=0;i51) return 0;} } } } } } if(acc==1) return 1; else return 0; } int c1patterns6() { int curword[6]; int i1,i2,i3,i4,i5,i6,acc=0; for(i6=0;i61) return 0;} } } } } } } if (acc==1) return 1; else return 0; } int c1patterns7() { int curword[7]; int i1,i2,i3,i4,i5,i6,i7,acc=0; for(i7=0;i71) return 0;} } } } } } } } if (acc==1) return 1; else return 0; } int sparse() { int i; for(i=0;ivv) vv=word[i]; for(j=1;j<=vv+1;j++) { nlet[j]++; word[l]=j; builtsp(l+1,lenp); nlet[j]--; } } } void builtpatterns(int l,int lenp) { int i,j,v; if (l==lenp) { for(i=0;iv) v=p[i]; for(j=1;j<=(v+1);j++) { p[l]=j; builtpatterns(l+1,lenp); } } } int main() { int lenp=4, max_n=12; fout=fopen("sppart_one4.txt","w"); builtpatterns(0,lenp); int i,j,i1,j1,j2,ii,sw; int ncc=0; for(i1=0;i1