int prin(int g[N][M],int i, int w) { if (i==0||w==0) { printf("%d",i); return 0; } if (g[i][w]==1) prin(g[N][M],i-1,w-w[i]); else prin(g[N][M],i-1,w); }
void prin(int i,int j) { if(i==j) printf("a%d",i); else { printf("("); prin(i,s[i][j]); prin((s[i][j]+1),j); printf(")"); } }
int main() { struct node* a=NULL; struct node* b=NULL; struct node* c=NULL; push(&a,50);push(&a,45);push(&a,40);push(&a,35);push(&a,30);push(&a,25);push(&a,20);push(&a,15); prin(a); push(&b,49);push(&b,46);push(&b,38);push(&b,25);push(&b,23);push(&b,13); prin(b); c=merg(a,b); prin(c); return 0; }
read_and_parse() { #define BUFLEN 512 char buf[BUFLEN]; /* this will have to be dynamically expanded */ int bufpos = 0; int ret; Value *v = NULL; Value *match_data; Value *pattern = vmake_cons(vmake_symbol_c("integer"), vmake_var(integer, (void **) &match_data)); while (1) { ret = read(0, buf + bufpos, BUFLEN - bufpos); if (ret < 0) { perror("read"); exit(1); } else { bufpos += ret; do { if (v != NULL) { free_value(v); v = NULL; } ret = parse(bufpos, buf, &v); if (ret > 0) { bcopy(buf + ret, buf, bufpos - ret); bufpos -= ret; printf("parsed: "); prin(stdout, v); fputc('\n', stdout); if (destructure(pattern, v)) { printf("match_data = "); prin(stdout, match_data); fputc('\n', stdout); } else { printf("destructure failed\n"); } free_value(v); } else printf("EOF\n"); } while (ret > 0); } } }
main(int argc, char *argv[]) { read_and_parse(); #if 0 Value *v; v = ALLOC_VALUE(); v->tag = cons; v->value.cons.car = ALLOC_VALUE(); v->value.cons.car->tag = symbol; v->value.cons.car->value.s.length = 6; v->value.cons.car->value.s.string = "symbol"; v->value.cons.cdr = ALLOC_VALUE(); v->value.cons.cdr->tag = cons; v->value.cons.cdr->value.cons.car = ALLOC_VALUE(); v->value.cons.cdr->value.cons.car->tag = string; v->value.cons.cdr->value.cons.car->value.s.length = 6; v->value.cons.cdr->value.cons.car->value.s.string = "string"; v->value.cons.cdr->value.cons.cdr = ALLOC_VALUE(); v->value.cons.cdr->value.cons.cdr->tag = integer; v->value.cons.cdr->value.cons.cdr->value.integer.i = 23; prin(stdout, v); fputc('\n', stdout); #endif }
int main(int argc,char **argv) { const int a=100; int zz[a]; prin(); return 0; }
CELLP princ_f(CELLP args) { CELLP result; FILE* nfp = cur_fpo; result = prin(args, ESCOFF); cur_fpo = nfp; return result; }
CELLP print_f(CELLP args) { CELLP result; FILE* nfp = cur_fpo; result = prin(args, ESCON); ec; fputc('\n', cur_fpo); cur_fpo = nfp; return result; }
void main() { int n,p[100],l,q,temp,k; clrscr(); printf("enter the no of matrices\n"); scanf("%ld",&n); printf("enter the orders of matrices\n"); for(i=0;i<(n+1);i++) scanf("%d",&p[i]); for(i=1;i<=n;i++) { m[i][i]=0; } for(l=2;l<=n;l++) { for(i=1;i<=(n-l+1);i++) { j=i+l-1; m[i][j]=32767; for(k=i;k<=(j-1);k++) { q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]; if(q<m[i][j]) { temp=m[i][j]; m[i][j]=q; q=temp; s[i][j]=k; } } } } printf("Cost matrix::\n"); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { printf("%d\t",m[i][j]); } printf("\n"); } printf("\nSequence matrix::\n"); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) printf("%d\t",s[i][j]); printf("\n"); } prin(1,n); printf("cost of matrix multi is =%d",m[1][n]); getch(); }
void prinlis(FILE *f, Value *v, int first) { switch(VTAG(v)) { case cons: /* continue printing list */ if (! first) putc(' ', f); prin(f, v->value.cons.car); prinlis(f, v->value.cons.cdr, 0); break; case nil: /* last elt in list */ putc(')', f); break; default: /* dotted pair */ putc(' ', f); putc('.', f); putc(' ', f); prin(f, v); putc(')', f); break; } }
int main() { int n,W,i; //int ans[1005];//要保存的游戏 scanf("%d%d",&n,&W);//输入 数目n和容量W for ( i = 1; i <= n; i++) scanf("%d",&w[i]); for ( i = 1; i <= n; i++) scanf("%d",&v[i]); DPKnapsack(w, v,n,W); prin(g[N][M],n,W); return 0; }
int main() { node *head,**s; head=addnode(5); head->next=addnode(15); head->next->next=addnode(20); head->next->next->next=addnode(38); head->next->next->next->next=addnode(67); s=&head; printf("address of s is %lld and s it's self %lld\n",&s,s); prin(head); printf("double pointer address is %lld \n",&head); insert_sort_way(&head,26); printf("double pointer address is %lld \n",&head); prin(head); insert_sort_way(&head,2); printf("double pointer address is %lld \n",&head); prin(head); return 0; }
int main(void) { int argn; int ** arg, **** exg, * grp; rel ** relh; argn = argnum(M); grp = grpnum(M, N, G); arg = estarg(argn, M); exg = estexg(N, grp, G); relh = estrelh(argn); relargexg(arg, exg, M, N, argn, grp, G, relh); prin(arg, argn, relh, exg, G, grp, N, M, C); frerel(rel, argn); freexg(exg, N, grp, G); frearg(arg, argn, M); fregrp(grp, N); return 0; }
void main() { int x; for(x=97;x<=122;x++) prin("%s",&x); getch(); }