Example #1
0
int main (int argc, char** argv) {

	struct arrayBagStack *a = (struct arrayBagStack *)malloc(sizeof(struct arrayBagStack));
	initArray(a);

	printf("Is stack array empty? %i\n", isEmptyArray(a));
	printf("Add 3, 2, 7, 14 & 9 to the stack, using bag.\n");
	addArray(a, 3);
	addArray(a, 2);
	addArray(a, 7);
	addArray(a, 14);
	addArray(a, 9);

	printf("the number at the top of the array is: %i\n", topArray(a));
	printf("How many numbers are now in the array? %i\n", sizeArray(a));

	printf("Remove last 2 values from the array, using stack implementation.\n");
	popArray(a);
	popArray(a);

	printf("How many numbers are now in the array? %i\n", sizeArray(a));
	printf("The number at the top of the array is now: %i", topArray(a));
	printf("\n");



	return 0;
}
Example #2
0
/* size_html_tbl:
 * Determine the size of a table by first determining the
 * size of each cell.
 */
static int
size_html_tbl(graph_t *g, htmltbl_t * tbl, htmlcell_t * parent, htmlenv_t * env)
{
    int i, wd, ht;
    int rv = 0;
    htmlfont_t savef;

    if (tbl->font)
	pushFontInfo(env, tbl->font, &savef);
    tbl->u.n.parent = parent;
    rv = processTbl(g, tbl, env);

    /* Set up border and spacing */
    if (!(tbl->data.flags & SPACE_SET)) {
	tbl->data.space = DEFAULT_CELLSPACING;
    }
    if (!(tbl->data.flags & BORDER_SET)) {
	tbl->data.border = DEFAULT_BORDER;
    }

    sizeArray(tbl);

    wd = (tbl->cc + 1) * tbl->data.space + 2 * tbl->data.border;
    ht = (tbl->rc + 1) * tbl->data.space + 2 * tbl->data.border;
    for (i = 0; i < tbl->cc; i++)
	wd += tbl->widths[i];
    for (i = 0; i < tbl->rc; i++)
	ht += tbl->heights[i];

    if (tbl->data.flags & FIXED_FLAG) {
	if (tbl->data.width && tbl->data.height) {
	    if ((tbl->data.width < wd) || (tbl->data.height < ht)) {
		agerr(AGWARN, "table size too small for content\n");
		rv = 1;
	    }
	    wd = ht = 0;
	} else {
	    agerr(AGWARN,
		  "fixed table size with unspecified width or height\n");
	    rv = 1;
	}
    }
    tbl->data.box.UR.x = MAX(wd, tbl->data.width);
    tbl->data.box.UR.y = MAX(ht, tbl->data.height);

    if (tbl->font)
	popFontInfo(env, &savef);
    return rv;
}