sábado, 26 de noviembre de 2011

colo cicular

class Cola{



{
p = u = -1;
tam = t;
vec =
}

{

{
vec[++u] = dato;

p = 0;

}

}

{



}

{

{
dato = vec[p];

u = p = -1;
int p, u, tam;int[] vec;public Cola(int t)new int[tam];public bool AGREGAR(int dato)if (!LLENA())if (u == 0)return true;return false;public bool LLENA()if (u == tam - 1)return true;return false;public bool EXTRAER(ref int dato)if (!VACIA())if (p == tam - 1)elsep++;

}

}

{



}

{

}

{

}
}

public partial class Form1 : Form{



{
InitializeComponent();
}

{
dataGridView1.AllowUserToAddRows =
dataGridView1.ReadOnly =
groupBox2.Enabled =
}

{
Cola C;int i, tam;public Form1()private void Form1_Load(object sender, EventArgs e)false;true;false;private void button1_Click(object sender, EventArgs e)try{
tam =
C =
dataGridView1.RowCount = tam;
groupBox1.Enabled =
groupBox2.Enabled =
}
Convert.ToInt32(textBox1.Text);new Cola(tam);false;true;catch{

textBox1.Text =
textBox1.Focus();
}
}

{
MessageBox.Show("¡Error!\nEl Dato no Puede ser Convertido a Entero.");"";private void button2_Click(object sender, EventArgs e)try{

{
i = 0;

C.AGREGAR(d);
dataGridView1[0, C.U()].Value = d;
}
if (!C.LLENA())int d = Convert.ToInt32(textBox2.Text);else{

textBox2.Text =
button2.Enabled =
button3.Enabled =
}
}
MessageBox.Show("¡Aviso!\nCola Llena.");"";false;true;catch{

textBox2.Text =
textBox2.Focus();
}
}

{

{

C.EXTRAER(
label3.Text =
dataGridView1[0, i++].Value =
}
MessageBox.Show("¡Error!\nEl Dato no Pudo Ser Introducido en la Cola.");"";private void button3_Click(object sender, EventArgs e)if (!C.VACIA())int dato = 0;ref dato);"Salida: " + dato.ToString();"";else{

label3.Text =
button2.Enabled =
button3.Enabled =
}
}

{
groupBox1.Enabled =
groupBox2.Enabled =
textBox1.Text =
textBox1.Focus();
}

{


{
op = 1;
}

{
op = 2;
}

{
op = 3;
}

{
op = 4;
}

{
op = 5;
}

{

C =
button2.Enabled =
comboBox1.Enabled =


C =
button2.Enabled =
comboBox1.Enabled =


C =
button2.Enabled =
comboBox1.Enabled =


C =
button2.Enabled =
comboBox1.Enabled =


C =
button2.Enabled =
comboBox1.Enabled =



comboBox1.Text =

}
}
}
MessageBox.Show("¡Aviso!\nCola Vacia.");"Salida: ";true;false;private void button4_Click(object sender, EventArgs e)true;false;"";private void button5_Click(object sender, EventArgs e)int op = 0;if (comboBox1.Text == "Int")if (comboBox1.Text == "String")if (comboBox1.Text == "Char")if (comboBox1.Text == "Double")if (comboBox1.Text == "Float")switch (op)case 1:new Cola(tam);false;false;break;case 2:new Cola(tam);false;false;break;case 3:new Cola(tam);false;false;break;case 4:new Cola(tam);false;false;break;case 5:new Cola(tam);false;false;break;default:MessageBox.Show("Solo las opciones mostradas estan disponibles");"";break;
return true;return false;public bool VACIA()if (p == -1)return true;return false;public int U()return u;public int P()return p;

No hay comentarios:

Publicar un comentario