Buscar

PilhaEnc

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

PilhaEnc/bin/Debug/PilhaEnc
__MACOSX/PilhaEnc/bin/Debug/._PilhaEnc
__MACOSX/PilhaEnc/bin/._Debug
__MACOSX/PilhaEnc/._bin
PilhaEnc/main.c
#include <stdio.h>
#include <stdlib.h>
#include "pilha_enc.h"
int main()
{
 tPilha p1;
 int tam = 0, to = 0;
 printf("Inicio do programa \n");
 cria(&p1); /* cria a pilha p1 */
 tam = tamanho(p1);
 printf("Tamanho inicial da pilha = %d \n", tam);
 push(&p1, 10);
 push(&p1, 20);
 push(&p1, 30);
 push(&p1, 40);
 tam = tamanho(p1);
 printf("\n\nTamanho atual da pilha = %d \n", tam);
 pop(&p1, &to);
 printf("Topo da pilha = %d \n", to);
 pop(&p1, &to);
 printf("Topo da pilha = %d \n", to);
 pop(&p1, &to);
 printf("Topo da pilha = %d \n", to);
 return 0;
}
__MACOSX/PilhaEnc/._main.c
��������Mac OS X �����	���2���½�������ï��������������������������������������ATTR�������ï���œ���S�������������������œ���S���com.dropbox.attributes���xœ«VJ)Ê/HʯˆOËÌIÍL‰ÏÉONÌQ²R¨VÊMLÎÈÌ�‰%–”��…R�K���%£üòL—€° ´ÜDÓb#çÀ¢²´â’r[[¥ÚÚZ�Îi��
PilhaEnc/obj/Debug/main.o
__MACOSX/PilhaEnc/obj/Debug/._main.o
PilhaEnc/obj/Debug/pilha_enc.o
__MACOSX/PilhaEnc/obj/Debug/._pilha_enc.o
__MACOSX/PilhaEnc/obj/._Debug
__MACOSX/PilhaEnc/._obj
PilhaEnc/pilha_enc.c
#include <stdlib.h>
#include "pilha_enc.h"
/** Cria uma Pilha */
void cria (tPilha *pilha) {
 *pilha = NULL;
}
/** Verifica se a Pilha está vazia*/
int vazia (tPilha pilha) {
 if (pilha == NULL)
 return 1;
 else
 return 0;
}
/** Obtém o tamanho da Pilha*/
int tamanho (tPilha pilha) {
 tPilha aux = pilha;
 int qtde = 0;
 while(aux != NULL){
 aux = aux->prox;
 qtde++;
 }
 return qtde;
}
/** Consulta o elemento do topo da Pilha
 A função retorna 0 se a pilha estiver vazia.
 Caso contrário, retorna 1.*/
int top (tPilha pilha, int *dado) {
 if (vazia(pilha)){
 return 0; /* Pilha vazia */
 }
 else{
 *dado = pilha->dado;
 return 1;
 }
}
/** Insere um elemento no topo da pilha.
 Retorna 0 se a memória for insuficiente.
 Caso contrário retorna 1 */
int push(tPilha *pilha, int valor) {
 tPilha novoNo;
 novoNo = malloc(sizeof(tNo));
 if (novoNo == NULL){
 return 0; /* mem. insufic. */
 }
 novoNo->dado = valor;
 novoNo->prox = *pilha;
 *pilha = novoNo;
 return 1;
}
/** Retira o elemento do topo da pilha.
 Retorna 0 se a pilha estiver vazia.
 Caso contrário retorna 1 */
int pop (tPilha *pilha, int *valor ) {
 tPilha aux;
 if (vazia(*pilha)) {
 return 0; /* pilha vazia */
 }
 aux = *pilha;
 *valor = aux->dado;
 *pilha = aux->prox;
 free(aux);
 return 1;
}
__MACOSX/PilhaEnc/._pilha_enc.c
��������Mac OS X �����	���2���½�������ï��������������������������������������ATTR�������ï���œ���S�������������������œ���S���com.dropbox.attributes���xœ«VJ)Ê/HʯˆOËÌIÍL‰ÏÉONÌQ²R¨VÊMLÎÈÌ�‰%–”��…R�K���¥ääòœbŸ¼”J/�ð¤œô€²$ÿìôt[[¥ÚÚZ�ÛT�Œ
PilhaEnc/pilha_enc.h
#ifndef PILHA_ENC_H_INCLUDED
#define PILHA_ENC_H_INCLUDED
typedef struct no {
 int dado; /* informação */
 struct no *prox; /* posição do topo da pilha */
} tNo; /* tipo do nó */
typedef tNo *tPilha; /* tipo pilha */
void cria(tPilha *pilha);
int vazia(tPilha pilha);
int tamanho(tPilha pilha);
int top(tPilha pilha, int *dado);
int push(tPilha *pilha, int valor);
int pop(tPilha *pilha, int *valor );
#endif // PILHA_ENC_H_INCLUDED
__MACOSX/PilhaEnc/._pilha_enc.h
��������Mac OS X �����	���2���½�������ï��������������������������������������ATTR�������ï���œ���S�������������������œ���S���com.dropbox.attributes���xœ«VJ)Ê/HʯˆOËÌIÍL‰ÏÉONÌQ²R¨VÊMLÎÈÌ�‰%–”��…R�K���¥@ÃÌ0G/ƒÔr�çŒâ4‹tç2ó€Ôr[[¥ÚÚZ�Á¨�V
PilhaEnc/PilhaEnc.cbp
 
	 
	 
		 
		 
		 
		 
			 
				 
				 
				 
				 
				 
					 
				
			
			 
				 
				 
				 
				 
				 
					 
				
				 
					 
				
			
		
		 
			 
		
		 
			 
		
		 
			 
		
		 
		 
			 
			 
			 
		
	
__MACOSX/PilhaEnc/._PilhaEnc.cbp
PilhaEnc/PilhaEnc.depend
# depslib dependency file v1.0
1444788886 source:/Users/tiagomaritan/Dropbox/ufpb-ci/2015.1/ED/Exemplos/PilhaEnc/pilha_enc.c
	<stdlib.h>
	"pilha_enc.h"
1444788727 /Users/tiagomaritan/Dropbox/ufpb-ci/2015.1/ED/Exemplos/PilhaEnc/pilha_enc.h
__MACOSX/PilhaEnc/._PilhaEnc.depend
PilhaEnc/PilhaEnc.layout
 
	 
	 
		 
			 
		
	
	 
		 
			 
		
	
	 
		 
			 
		
	
__MACOSX/PilhaEnc/._PilhaEnc.layout
__MACOSX/._PilhaEnc

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais