bool Archive::archive_dissimilar(Point p){ if(size == 0){ add(p,0); return true; } else{ bool dissimilar = true; ArchivePoint *mostsimilar = nullptr; int mostsimilarpos; ArchivePoint *pp = first; int i; int pos = size; for(i = 0; i < size; i++){ //check dissimilarity, look for most similar double dist = pp->distance(p); if(dist < Dmin){ dissimilar = false; //cases c or d if(mostsimilar == nullptr){ mostsimilar = pp; mostsimilarpos = i;} else if(pp->distance(p) < mostsimilar->distance(p)) { mostsimilar = pp; mostsimilarpos = i;} } if(pos == size && pp->getF() < p.getF()) pos = i; //look for position in the archive pp = pp->getNext(); } if(dissimilar){ if(pos < maxsize){ // cases a and b add(p,pos); return true; } } else { if(p.getF() > (*this)[0]->getF()){ // case c deletep(mostsimilarpos); add(p,0); return true; } else if(p.getF() > mostsimilar->getF() && mostsimilar->distance(p) < Dsim){ //case d deletep(mostsimilarpos); add(p,pos); return true; } } } return false; }
void main() { clrscr(); int x,i; FILE* f,*f1; char s[80],s1[80],s2[80]; //x=mkdir("c:\\borlandc\\A1"); //x=mkdir("c:\\P2"); //copyf("e:\\P1\\","e:\P2\\","F1.txt"); //copyp("e:\\P1\\","e:\\P2\\","F1"); //deletef("e:\\P1\\","F1.txt"); strcpy(so,"c:\\borlandc\\"); deletep("c:\\borlandc\\A1\\","B1"); getch(); }
void deletep(char *s,char *sss) { char s1[80],s3[80],s4[80],s2[80]; int x,k=0,k1=0,i,j; strcpy(s1,s); strcat(s1,sss); strcpy(s3,s1); strcat(s3,"\\*.*"); struct ffblk full; x=findfirst(s3,&full,0); if (x==0) { strcat(s1,"\\"); struct ffblk full; x=findfirst(s3,&full,0); while (!x) { deletef(s1,full.ff_name); x=findnext(&full); } } strcpy(s1,s); strcat(s1,sss); strcpy(s4,s1); strcat(s4,"\\*."); struct ffblk full1; x=findfirst(s4,&full1,0x10); while (!x) { x=findnext(&full1); k++; } if (k>2) { strcat(s1,"\\"); struct ffblk full1; x=findfirst(s4,&full1,0x10); while (!x) { if (full1.ff_name[0]!='.') { cout<<"1 "<<endl; puts(s1); getch(); deletep(s1,full1.ff_name); } x=findnext(&full1); } } else { strcpy(s1,s); strcat(s1,sss); x=rmdir(s1); cout<<"Rem "<<endl; puts(s1); strcpy(s1,s); strcpy(s4,s1); strcat(s4,"*."); struct ffblk full1; x=findfirst(s4,&full1,0x10); k=0; while (!x) { x=findnext(&full1); k++; } if (k>2) { return; cout<<"Sdelan vozvrat"<<endl; } else { k=0; strcpy(s1,""); strcpy(s2,""); for (i=0; s[i]!='\0'; i++) if (s[i]=='\\') k++; k--; for (i=0; i<k; i++) { for (j=0; s[j]!='\\'; j++); strncpy(s1,s,j+1); s1[j+1]='\0'; strcat(s2,s1); strcpy(s,&s[j+1]); } for(i=0; s[i]!='\\'; i++); s[i]='\0'; cout<<"2 "<<endl; puts(s2); getch(); if (strcmp(so,s2)==0) return; deletep(s2,s); } } }