Example #1
0
void init_hashTable(t_hashTable *table, int size){
	int start = 0;
	table->lista = (t_lista*)malloc(size * sizeof(t_lista));
	table->size = size;
	for(start = 0; start< size; start++){
		makenull(&table->lista[start]);
	};

};
void DrzewoCzerCzar::makenull(Node *root)
{
	while (root->left != guard || root->right != guard)
	{
		if (root->left != guard) { makenull(root->left); }
		if (root->right != guard) { makenull(root->right); }
	}

	if (root->left == guard && root->right == guard && root != guard) 
	{ 
		if (root->up != guard)
		{
			if (root == root->up->left) root->up->left = guard;
			else if (root == root->up->right) root->up->right = guard;
		}

		delete root; 
	}
}
Example #3
0
void stack::pop(void){ 
if(empty()) 
cout<<"There is nothing!"<<endl; 
else if(front==rear){ 
makenull(); 
cout<<"This is end!"<<endl; 
} 
else 
rear=rear->pre; 
} 
// zerowanie drzewa
void DrzewoCzerCzar::makenull()
{
	makenull(root);
	root = guard;
}
DrzewoCzerCzar::~DrzewoCzerCzar()
{
	makenull();
	delete root;
}
int main(void)
{
	stos *stos;
	int liczba;
	int flaga=1;
	int wym;

	printf("podaj maksymalna ilosc elementow stosu: ");
	scanf_s("%d", &wym);
	stos=makenull(wym);

	while(flaga==1)
	{
		switch(menu())
		{
		case 1:
			printf("MENU:\t1 - Push\n\n");
			printf("podaj liczbe: ");
			scanf_s("%d", &liczba);
			if(full(stos))
				printf("stos jest pelny\n");
			else
			{
				push(stos, liczba);
				printf("umieszczono na stosie\n");
			}
			break;
		case 2:
			printf("MENU:\t2 - Pop\n\n");
			if(empty(stos))
				printf("stos jest pusty\n");
			else
				printf("twoja liczba to: %d\n", pop(stos));
			break;
		case 3:
			printf("MENU:\t3 - Pokaz top\n\n");
			if(empty(stos))
				printf("stos jest pusty\n");
			else
				printf("liczba z top to: %d\n", top(stos));
			break;
		case 4:
			printf("MENU:\t4 - Wydrukuj ca³y stos\n\n");
			print(stos);
			break;
		case 5:
			printf("MENU:\t5 - Liczba elementow stosu\n");
			if(empty(stos))
				printf("stos jest pusty\n");
			else
				printf("%d", size(stos));
			break;
		case 6:
			printf("MENU:\t6 - Wyczysc stos\n\n");
			printf("stos wysczyszczony\n");
			clear(stos);
			break;
		case 0:
			printf("MENU:\t0 - Wyjscie\n\n");
			printf("ZAMYKANIE...\npamiec po stosie zostanie zwolniona\n");
			flaga=0;
			break;
		default:
			printf("blad, sproboj ponownie\n");
			break;
		}
		printf("\n> > > potwierdz enterem < < <\n");
		fflush(stdin);
		getchar();
		system("cls");
	}

	del(stos);

	return 0;
}