Documentos de Académico
Documentos de Profesional
Documentos de Cultura
void TDACola::Crea(){
i=1;
while (i<=max){
v[i]=0;
i++;
}
fin=0;
inicio=1;
}
bool TDACola::Vacia(){
return inicio==fin+1;
}
int TDACola::Primero(){
return v[inicio];
}
int TDACola::Siguiente(int dir){
if (dir==max) {
return 1;
} else {
return dir+1;
}
}
void TDACola::Poner(int ele){
if (Siguiente(Siguiente(fin))!=inicio) {
fin=Siguiente(fin);
v[fin]=ele;
}
}
void TDACola::Sacar(int &ele){
if (!Vacia()) {
ele=v[inicio];
inicio=Siguiente(inicio);
} else {
fin=0;
inicio=1;
}
}
BICOLA
//Implementacion
void TDABicola::Crea(){
i=1;
while (i<=maxi){
v[i]=0;
i++;
}
fin=0;
inicio=1;
}
bool TDABicola::Vacia(){
return inicio==fin+1;
}
int TDABicola::Primero(){
return v[inicio];
}
int TDABicola::Ultimo(){
return v[fin];
}
int TDABicola::Siguiente(int dir){
if (dir==maxi) {
return 1;
} else {
return dir+1;
}
}
int TDABicola::Anterior(int dir){
if (dir==1) {
return maxi-1;
} else {
return dir-1;
}
}
void TDABicola::Poner(int ele){
if (Siguiente(Siguiente(fin))!=inicio) {
fin=Siguiente(fin);
v[fin]=ele;
}
}
void TDABicola::PonerFrente(int ele){
if (Anterior(Anterior(inicio))!=fin) {
inicio=Anterior(inicio);
v[inicio]=ele;
}
}
void TDABicola::Sacar(int &ele){
if (!Vacia()) {
ele=v[inicio];
inicio=Siguiente(inicio);
} else {
fin=0;
inicio=1;
}
}
void TDABicola::SacarUltimo(int &ele){
if (!Vacia()) {
ele=Ultimo();
fin=Anterior(fin);
} else {
fin=0;
inicio=1;
}
}
MATIZ DISPERSA
void MatrizD::Crea(){
columnas=0;
filas=0;
numero=0;
repetido=0;
}
void MatrizD::Dimensionar(int f, int c){
columnas=c;
filas=f;
}
int MatrizD::DimensionFila(){
return filas;
}
int MatrizD::DimensionColumna(){
return columnas;
}
int MatrizD::LocalizaIndice(int f, int c){
bool b=false;
int lug=0, x=1;
while (b==false && x<=numero){
if (vf[x]==f) {
if (vc[x]==c) {
b=true;
lug=x;
} else {
x++;
}
} else {
x++;
}
}
return lug;
}
} else {
if (numero<=filas*columnas) {
numero++;
vf[numero]=f;
vc[numero]=c;
ve[numero]=ele;
}
}
}