void main() {sqlist L; int i,j,k,b,n,e,m,a,cur_e,pre_e,next_e,s; initlist(L); cout<<"初始化后的基值地址:"<<L.elem<<" L.length=:"<<L.length<<" L.listsize=:"<<L.listsize<<endl; cout<<"新建一顺序表."<<endl; cout<<"当前表是否为空表"<<listempty(L)<<endl; cout<<"定义该线性表长度:"<<endl; cin>>a; cout<<"分别输入线性表的各个元素,按ENTER"<<endl; for(k=1;k<=a;k++){ cin>>j; i=listinsert(L,k,j);} for(b=1;b<=a;b++) cout<<L.elem[b-1]<<endl; listlength(L); cout<<"当前表长:"<<L.length<<endl; cout<<"输入要取的数的位置n(n<=a)"<<endl; cin>>n; getelem(L,n,e); //cout<<L.elem[n-1]<<endl; cout<<e<<endl; cout<<"与该数相等的的一个数的位序为:"<<locateelem(L,e,compare)<<endl; cout<<"输入要取前驱的数的位置m(<=a)"<<endl; cin>>m; getelem(L,m,cur_e); if(priorelem(L,cur_e,pre_e)) cout<<"cur_e的前驱为:"<<pre_e<<endl; else cout<<"该元素没前驱"<<endl; nextelem(L,cur_e,next_e); if(nextelem(L,cur_e,next_e)) cout<<"cur_e的后继为:"<<next_e<<endl; else cout<<"该元素没后继"<<endl; cout<<"奇数在前,偶数在后,并输出"<<endl; move(L); for(s=1;s<=a;s++) cout<<L.elem[s-1]<<endl; cout<<"输入要删元素的位序m(<=a)"<<endl; cin>>m; listdelete(L,m,e); cout<<"被删的元素为:"<<e<<endl; cout<<"删除元素后表长为"<<L.length<<endl; //listtraverse(L,visit); cout<<"置为空表"<<clearlist(L)<<endl; cout<<"销毁线性表"<<destroylist(L)<<endl; }
int main() { int x[6]={3,6,5,2,8,9},a,c,d,e=8,g; bool b,f; sqlist *A; createlist(A,x,6); listinsert(A,4,1); listdelete(A,2,g); displist(A); a=listlength(A); b=getelem(A,3,c); d=locateelem(A,e); printf("%d\n",a); printf("%d\n",b); printf("%d\n",d); printf("%d\n",f); system("pause"); return 0; }
int main() { int x[]={32,42,334,22,67,89}; int a,c,d,f; bool b,e,g; linklist *A; createlistr(A,x,6); b=getelem(A,4,c); d=locateelem(A,67); listinsert(A,4,76); listdelete(A,2,f); displist(A); a=listlength(A); printf("%d\n",a); printf("%d\n",c); printf("%d\n",d); printf("%d\n",f); system("pause"); return 0; }
void mn_delete(cml_node *mn) { strdelete(mn->name); strdelete(mn->banner); listclear(mn->rules_using); if (mn->visibility_expr != 0) expr_destroy(mn->visibility_expr); if (mn->saveability_expr != 0) expr_destroy(mn->saveability_expr); /* only remove the list structure, all nodes are deleted seperately */ listclear(mn->children); if (mn->expr != 0) expr_destroy(mn->expr); atom_dtor(&mn->value); listclear(mn->transactions_guarded); listclear(mn->bindings); range_delete(mn->range); listdelete(mn->enumdefs, cml_enumdef, cml_enumdef_delete); listclear(mn->dependants); listclear(mn->dependees); strdelete(mn->help_text); g_free(mn); }
int main (int argc, char const * argv []) { extern const unsigned char ct_unescape []; static char const * optv [] = { "print user/group names in alphabetcial order in columns", PUTOPTV_S_DIVINE, "c:e:gHnw:uRT", "c n\tcolumn count is (n) [" LITERAL (COUNT) "]", "w n\tscreen width is (n) [" LITERAL (WIDTH) "]", "e s\texpression is s [.+]", "g\tlist groupnames", "H\tregular expression help", "u\tlist usernames", "n\tnumber list items", "R\tregular expression help", "T\tescape sequence rules", (char *) (0) }; LIST list; regexp * regex = (regexp *) (0); char const * expression = ".+"; flag_t flags = (flag_t) (0); size_t count = COUNT; size_t width = WIDTH; bool index = false; int c; while (~ (c = getoptv (argc, argv, optv))) { switch (c) { case 'w': width = uintspec (optarg, 1, 132); break; case 'c': count = uintspec (optarg, 1, 16); break; case 'g': _setbits (flags, WHOM_B_GRP); break; case 'e': expression = optarg; break; case 'n': index = true; break; case 'u': _setbits (flags, WHOM_B_USR); break; case 'H': _setbits (flags, WHOM_B_SHW); break; case 'R': regexhelp (); exit (0); case 'T': chruescmap (ct_unescape, REGEX_C_ESC); exit (0); default: break; } } argc -= optind; argv += optind; if (_anyset (flags, (WHOM_B_SHW))) { regex = regexmake (expression); regexshow (regex); return (0); } if (_allclr (flags, (WHOM_B_USR | WHOM_B_GRP))) { _setbits (flags, (WHOM_B_USR | WHOM_B_GRP)); } setpwent (); listcreate (& list, _LISTSIZE); regex = regexmake (expression); function (& list, regex, flags); regex = regexfree (regex); listcolumn (& list, stdout, width, count, index); listdelete (& list); endpwent (); exit (0); }
int Proutespline (Pedge_t *edges, int edgen, Ppolyline_t input, Ppoint_t *evs, Ppolyline_t *output) { #if 0 Ppoint_t p0, p1, p2, p3; Ppoint_t *pp; Pvector_t v1, v2, v12, v23; int ipi, opi; int ei, p2ei; Pedge_t *e0p, *e1p; #endif Ppoint_t *inps; int inpn; /* unpack into previous format rather than modify legacy code */ inps = input.ps; inpn = input.pn; #if 0 if (!(p2es = (p2e_t *) malloc (sizeof (p2e_t) * (p2en = edgen * 2)))) { prerror ("cannot malloc p2es"); abort (); } for (ei = 0, p2ei = 0; ei < edgen; ei++) { if (edges[ei].a.x == edges[ei].b.x && edges[ei].a.y == edges[ei].b.y) continue; p2es[p2ei].pp = &edges[ei].a; p2es[p2ei++].ep = &edges[ei]; p2es[p2ei].pp = &edges[ei].b; p2es[p2ei++].ep = &edges[ei]; } p2en = p2ei; qsort (p2es, p2en, sizeof (p2e_t), cmpp2efunc); elist = NULL; for (p2ei = 0; p2ei < p2en; p2ei += 2) { pp = p2es[p2ei].pp; #if DEBUG >= 1 fprintf (stderr, "point: %d %lf %lf\n", p2ei, pp->x, pp->y); #endif e0p = p2es[p2ei].ep; e1p = p2es[p2ei + 1].ep; p0 = (&e0p->a == p2es[p2ei].pp) ? e0p->b : e0p->a; p1 = (&e0p->a == p2es[p2ei + 1].pp) ? e1p->b : e1p->a; if (LT (p0, pp) && LT (p1, pp)) { listdelete (e0p), listdelete (e1p); } else if (GT (p0, pp) && GT (p1, pp)) { listinsert (e0p, *pp), listinsert (e1p, *pp); } else { if (LT (p0, pp)) listreplace (e0p, e1p); else listreplace (e1p, e0p); } } #endif /* generate the splines */ evs[0] = normv (evs[0]); evs[1] = normv (evs[1]); opl = 0; growops (4); ops[opl++] = inps[0]; if (reallyroutespline (edges, edgen, inps, inpn, evs[0], evs[1]) == -1) return -1; output->pn = opl; output->ps = ops; #if 0 fprintf (stderr, "edge\na\nb\n"); fprintf (stderr, "points\n%d\n", inpn); for (ipi = 0; ipi < inpn; ipi++) fprintf (stderr, "%f %f\n", inps[ipi].x, inps[ipi].y); fprintf (stderr, "splpoints\n%d\n", opl); for (opi = 0; opi < opl; opi++) fprintf (stderr, "%f %f\n", ops[opi].x, ops[opi].y); #endif return 0; }
void function (char const * path, char * file, size_t width, size_t count, bool index, flag_t flags) { DIR * dir; LIST list; listcreate (& list, _LISTSIZE); printf ("%s\n", path); if ((dir = opendir (path))) { struct dirent * dirent; struct stat statinfo; while (* file) { file++; } * file++ = PATH_C_EXTENDER; while ((dirent = readdir (dir))) { char const * sp = dirent->d_name; if (* sp == FILE_C_EXTENDER) { sp++; } if (* sp == FILE_C_EXTENDER) { sp++; } if (* sp == (char) (0)) { continue; } strcpy (file, dirent->d_name); if (lstat (path, & statinfo)) { error (0, errno, "%s", path); continue; } if (S_ISDIR (statinfo.st_mode)) { if (flags & (FIND_B_DIR)) { listinsert (& list, file); } continue; } if (S_ISLNK (statinfo.st_mode)) { if (flags & (FIND_B_LNK)) { listinsert (& list, file); } continue; } if (S_ISREG (statinfo.st_mode)) { if (flags & (FIND_B_REG)) { listinsert (& list, file); } continue; } } * -- file = (char) (0); closedir (dir); } listcolumn (& list, stderr, width, count, index); listdelete (& list); return; }