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;

domingo, 13 de noviembre de 2011

En este programa utilizamos recursividad

class Matematicas{


{


string x;public int Factorial_R(int n)int f = 1;if (n == 0 || n == 1)return f;elsef = n * Factorial_R(n - 1);

}

{


return f;public int Sumatoria_R(int n)int f = 0;if (n == 0 || n == 1)return f;elsef = n + Factorial_R(n - 1);

}

{

return f;public static int Fibonacci(int n)if (n == 1 || n == 2)return 1;else{


}
}

{

int resul = Fibonacci(n - 1) + Fibonacci(n - 2);return resul;public int Combinacion_R(int n, int r)if ((n == r) || (r == 0) || (n == 1))return 1;else
}

{
x +=

Invertir(n / 10);

}
}

public partial class Form1 : Form{

{
InitializeComponent();
}


{



}

{
}

{



{

res=obb.Factorial_R(n);
textBox7.Text = res.ToString();
}

{

textBox7.Text = obb.Invertir(n).ToString();
}

{

res =
textBox7.Text = res.ToString();
}


{
textBox2.Visible =


res = obb.Combinacion_R(n, n2);
textBox7.Text = res.ToString();
}

}
public Form1()private void button1_Click(object sender, EventArgs e)private void button2_Click(object sender, EventArgs e)private void button2_Click_1(object sender, EventArgs e)Matematicas obb = new Matematicas();int res=0;if (comboBox1.SelectedIndex == 0)int n = Convert.ToInt32(textBox1.Text);if (comboBox1.SelectedIndex == 1)int n = Convert.ToInt32(textBox1.Text);if (comboBox1.SelectedIndex == 2)int n = Convert.ToInt32(textBox1.Text);Matematicas.Fibonacci(n);if (comboBox1.SelectedIndex == 3)false; ;int n = Convert.ToInt32(textBox1.Text);int n2 = Convert.ToInt32(textBox2.Text);
return Combinacion_R(n - 1, r) + Combinacion_R(n - 1, r - 1);public string Invertir(int n)Convert.ToString(n % 10) + " ";if (n >= 10)return x;

animacion de un componente

public partial class Form1 : Form{

{
InitializeComponent();
}


{
timer1.Enabled =
}

{
timer1.Enabled =
}

{

{
pictureBox1.Left++;

lr =
}
public Form1()bool lr = true, ud = true;private void Form1_MouseClick(object sender, MouseEventArgs e)true;private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)false;private void timer1_Tick(object sender, EventArgs e)if (lr == true)if (pictureBox1.Left == this.ClientSize.Width - pictureBox1.Width+10)false;else{
pictureBox1.Left--;

lr =
}

{
pictureBox1.Top++;

ud =
}
if (pictureBox1.Left == -10)true;if (ud == true)if (pictureBox1.Top == this.ClientSize.Height - pictureBox1.Height+10)false;else{
pictureBox1.Top--;

ud =
}
}
if (pictureBox1.Top == -10)true;