viernes, 23 de septiembre de 2011

En este progrma utilizamos string, stringbulder y arreglos

static
{
void Main(string[] args)//utilizando string
s1 += s2 + s3 + s4 + s5;
string s1= " Hola, ", s2=" porfavor ", s3=" ingrese ", s4=" una ", s5=" palabra.";// metodo que concatena

cad1 =
cad2 =
Console.WriteLine(s1);string cad1 = "", cad2 = "";Convert.ToString(Console.ReadLine());Convert.ToString(Console.ReadLine());//utilizando strigbuilder
StringBuilder sb = new StringBuilder(cad1);for (int i = 0, j = cad1.Length -1; i < cad1.Length; i++, j--)//doble forsb[i] = cad1[j];Console.WriteLine(" Cadena invertida: " + sb);//utilizando un arreglo de char


{


convoc++;

conmay++;

conmin++;
}


}
}
char[] voc = { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' };int convoc = 0,conmay = 0, conmin = 0;for (int i = 0; i < cad1.Length; i++)for (int j = 0; j < voc.Length; j++)if (cad1[i] == voc[j])if (Char.IsUpper(cad1[i]) == true)if (Char.IsLower(cad1[i]) == true)Console.WriteLine("\n Numero de Vocales " + convoc + "\n" + "\n Numero de Mayusculas " + conmay + "\n" + "\n Numero de Minusculas " + conmin); Console.ReadKey();

miércoles, 21 de septiembre de 2011

Este programa muestra el decempeño de empleados que venden x preducto

class
{
T[,] mat;

{
mat =
}

{


}

{

}

{

}
}


{
T[] vec;

{
vec =
}

{


}

{

}
}

public partial class Form1 : Form{



{
InitializeComponent();
}

{
dataGridView1.RowCount =

dataGridView1[0, i].Value =
dataGridView1[0,
}

{
button1.Enabled = button2.Enabled = button3.Enabled = button4.Enabled =
dataGridView2.RowCount = 2;
dataGridView1.AllowUserToAddRows = dataGridView2.AllowUserToAddRows =
}

{
button1.Enabled =



{
dataGridView1[j, i].Value = CAA.Next(0, 20).ToString();
}
}

{
button1.Enabled =


{
dataGridView1[j, i].Value =
}
}

{
button1.Enabled =

{

{0,2,2,2,2,2},
{0,2,2,2,2,2},
{0,1,1,1,1,1},
{0,1,1,1,1,1}};


{
dataGridView1[j, i].Value = CA[i,j].ToString();
}
}
Matriz<int> matA;Vector<double> vecP;public Form1()private void numericUpDown1_ValueChanged(object sender, EventArgs e)Convert.ToInt32(numericUpDown1.Value) + 1;for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)"Emp - RM-" + (i + 1).ToString();Convert.ToInt32(numericUpDown1.Value)].Value = "Cant. Product.";private void Form1_Load(object sender, EventArgs e)false;false;private void radioButton2_CheckedChanged(object sender, EventArgs e)true;Random CAA = new Random();for(int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)for (int j = 1; j < 6; j++)private void radioButton1_CheckedChanged(object sender, EventArgs e)true;for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)for (int j = 1; j < 6; j++)"";private void radioButton3_CheckedChanged(object sender, EventArgs e)true;if (Convert.ToInt32(numericUpDown1.Value) <= 5)int[,] CA = {{1,2,2,2,2,2},for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)for (int j = 1; j < 6; j++)else{

numericUpDown1.Focus();
radioButton1.Focus();
}
}

{
button2.Enabled =
matA =



{
matA[i, j] =
}
vecP =

vecP[j] =
}

{
button3.Enabled =



{
tV = 0;

{
tV += matA[i, j] * vecP[j-1];
}
dataGridView1[6, i].Value = tV.ToString();
}

{
tP = 0;

{
tP += matA[i, j];
dataGridView1[j,
}
}
}

{
button4.Enabled =
button2.Enabled = button3.Enabled =


dataGridView1[6, i].Value =
}

{
button4.Enabled =


dataGridView1[6, i].Value =
}

{


{

{
meV =
label5.Text =
}
}


{

{
maV =
label6.Text =
}
}


{

{
aCMen =
label7.Text =
}
}


{

{
aCMas =
label8.Text =
}
}

}

{
button1.Enabled =


{
dataGridView1[j, i].Value =
}
textBox1.Text = textBox2.Text =

dataGridView2[j, 0].Value =
dataGridView1.RowCount = 0;
numericUpDown1.Value = 0;
}
}
MessageBox.Show("Error! Esta funcion esta disponible solo para 5 Empleados o Menos");private void button1_Click(object sender, EventArgs e)true;new Matriz<int>(Convert.ToInt32(numericUpDown1.Value), 7);for(int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)for (int j = 1; j < 6; j++)Convert.ToInt32(dataGridView1[j, i].Value);new Vector<double>(5);for (int j = 0; j < 5; j++)Convert.ToDouble(dataGridView2[j,0].Value);private void button2_Click(object sender, EventArgs e)true;double tV;int tP;for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)for (int j = 1; j < 6; j++)for (int j = 1; j < 6; j++)for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)Convert.ToInt32(numericUpDown1.Value)].Value = tP.ToString();private void button3_Click(object sender, EventArgs e)true;false;double tVyT = Convert.ToDouble(textBox1.Text);for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)Convert.ToDouble(dataGridView1[6, i].Value) + tVyT;private void button4_Click(object sender, EventArgs e)false;double IVA = Convert.ToDouble(textBox2.Text);for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)Convert.ToDouble(dataGridView1[6, i].Value) * (1 + (IVA/100));private void button5_Click(object sender, EventArgs e)double meV = 1000000;for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)if (Convert.ToDouble(dataGridView1[6, i].Value) < meV)Convert.ToDouble(dataGridView1[6, i].Value);"Empleado que Vendio Menos: Emp - RM-" + (i + 1).ToString();double maV = 0;for (int i = 0; i < Convert.ToInt32(numericUpDown1.Value); i++)if (Convert.ToDouble(dataGridView1[6, i].Value) > maV)Convert.ToDouble(dataGridView1[6, i].Value);"Empleado que Vendio Más: Emp - RM-" + (i + 1).ToString();int aCMen = 1000000;for (int j = 1; j < 6; j++)if (Convert.ToDouble(dataGridView1[j, Convert.ToInt32(numericUpDown1.Value)].Value) < aCMen)Convert.ToInt32(dataGridView1[j, Convert.ToInt32(numericUpDown1.Value)].Value);"Artículo Menos Solicitado: #" + j.ToString();int aCMas = 0;for (int j = 1; j < 6; j++)if (Convert.ToDouble(dataGridView1[j, Convert.ToInt32(numericUpDown1.Value)].Value) > aCMas)Convert.ToInt32(dataGridView1[j, Convert.ToInt32(numericUpDown1.Value)].Value);"Artículo Más Solicitado: #" + j.ToString();private void button6_Click(object sender, EventArgs e)true;for (int i = 0; i <= Convert.ToInt32(numericUpDown1.Value); i++)for (int j = 1; j < 7; j++)"";"";for (int j = 0; j < 5; j++)"";
class Vector<T>public Vector(int nC)new T[nC];public T this[int c]get { return vec[c]; }set { vec[c] = value; }public int COLget { return vec.GetLength(1); }
Matriz<T>public Matriz(int nR, int nC)new T[nR, nC];public T this[int r, int c]get { return mat[r, c]; }set { mat[r, c] = value; }public int RENget { return mat.GetLength(0); }public int COLget { return mat.GetLength(1); }

martes, 13 de septiembre de 2011

Este programa maneja matrices

public partial class Form1 : Form{


{
InitializeComponent();
}


{
dgv1.RowCount = dgv2.RowCount = dgv3.RowCount =
}

{
dgv1.ColumnCount = dgv2.ColumnCount = dgv3.ColumnCount =
}

{
dgv1.Focus();
dgv2.Focus();
}

{





{
dgv1[j, i].Value = r.Next(0, 11);
dgv2[j, i].Value = r.Next(0, 11);
}
}

{

{11,12,13,14,15,16,17,18,19,20},
{21,22,23,24,25,26,27,28,29,30},
{31,32,33,34,35,36,37,38,39,40},
{41,42,43,44,45,46,47,48,49,50},
{51,52,53,54,55,56,57,58,59,60},
{61,62,63,64,65,66,67,68,69,70},
{71,72,73,74,75,76,77,78,79,80},
{81,82,83,84,85,86,87,88,89,90},
{91,92,93,94,95,96,97,98,99,100}};



{


dgv1.Rows[ren].Cells[col].Value =
}
Matriz mat = new Matriz();public Form1()private void numericUpDown1_ValueChanged(object sender, EventArgs e)int.Parse(numericUpDown1.Value.ToString());private void numericUpDown2_ValueChanged(object sender, EventArgs e)int.Parse(numericUpDown2.Value.ToString());private void radioButton1_CheckedChanged(object sender, EventArgs e)private void radioButton2_CheckedChanged(object sender, EventArgs e)int ren = Convert.ToInt32(numericUpDown1.Value);int col = Convert.ToInt32(numericUpDown2.Value);Random r= new Random();for(int i = 0; i < ren; i++)for (int j = 0; j < col; j++)private void radioButton3_CheckedChanged(object sender, EventArgs e)int[,] aux ={{1,2,3,4,5,6,7,8,9,10},int nr = Convert.ToInt32(numericUpDown1.Value);int nc = int.Parse(numericUpDown2.Value.ToString());if ((nr >= 3 && nr <= 10) && (nc >= 3 && nc <= 10))for (int ren = 0; ren < dgv1.RowCount; ren++)for (int col = 0; col < dgv1.ColumnCount; col++)int.Parse(aux[ren, col].ToString());else{MessageBox.Show("solo se aceptan valores entre 1 y 10 \n introduce otra vez los valores: ");//numericUpDown1.Value=radioButton1.Checked =
radioButton2.Checked =
radioButton3.Checked =

}
}

{



{

mat.Multiplicacion(dgv1, dgv2, dgv3);
}
false;false;false;return;private void button1_Click(object sender, EventArgs e)int ren = Convert.ToInt32(numericUpDown1.Value);int col = Convert.ToInt32(numericUpDown2.Value);if (ren == col)else
}


{


mat.Suma(dgv1, dgv2, dgv3);
}

{


mat.Resta(dgv1, dgv2, dgv3);
}

{




{


{
suma +=
j++;
}
textBox5.Text = suma.ToString();
}
MessageBox.Show("Error! Matriz no Apta para la Funcion de Multiplicacion.");private void button4_Click(object sender, EventArgs e)int ren = Convert.ToInt32(numericUpDown1.Value);int col = Convert.ToInt32(numericUpDown2.Value);private void button5_Click(object sender, EventArgs e)int ren = Convert.ToInt32(numericUpDown1.Value);int col = Convert.ToInt32(numericUpDown2.Value);private void radioButton8_CheckedChanged(object sender, EventArgs e)int ren = Convert.ToInt32(numericUpDown1.Value);int col = Convert.ToInt32(numericUpDown2.Value);int suma = 0;if (ren == col)int j = 0;for (int i = 0; i < col; i++)Convert.ToInt32(dgv1[j, i].Value);else
}

{



{



{
suma +=
j--;
}
textBox6.Text = suma.ToString();
}
MessageBox.Show("Error! Matriz no apta para la suma de la Diagonal Principal.");private void radioButton9_CheckedChanged(object sender, EventArgs e)int ren = Convert.ToInt32(numericUpDown1.Value);int col = Convert.ToInt32(numericUpDown2.Value);if (ren == col)int j = col - 1;int suma = 0;for (int i = 0; i < ren; i++)Convert.ToInt32(dgv1[j, i].Value);else
}

{
textBox7.Text =
}

{
textBox8.Text =
}

{
}

class Matriz{



{
}

{
ren = r;
col = c;
mat =
}

{

{

{
dgv3[j, i].Value =
}
}
}

{

{

{
dgv3[j, i].Value =
}
}
}

{


{
dgv3[j, i].Value = 0;

dgv3[j, i].Value =
}
}

{



mayor =

}

{



menor =

}
}
private int[,] mat;int ren, col;public Matriz()public Matriz(int r, int c)new int[ren, col];public void Suma(DataGridView dgv1, DataGridView dgv2, DataGridView dgv3)for (int i = 0; i < ren; i++)for (int j = 0; j < col; j++)Convert.ToInt32(dgv1[j, i].Value) + Convert.ToInt32(dgv2[j, i].Value);public void Resta(DataGridView dgv1, DataGridView dgv2, DataGridView dgv3)for(int i = 0; i < ren; i++)for(int j = 0; j < col; j++)Convert.ToInt32(dgv1[j, i].Value) + Convert.ToInt32(dgv2[j, i].Value); public void Multiplicacion(DataGridView dgv1, DataGridView dgv2, DataGridView dgv3)for (int i = 0; i < ren; i++)for (int j = 0; j < ren; j++)for (int k = 0; k < ren; k++)Convert.ToInt32(dgv3[j, i].Value) + Convert.ToInt32(dgv1[k, i].Value) * Convert.ToInt32(dgv2[j, k].Value);public int Mayor(DataGridView dgv)int mayor = Convert.ToInt32(dgv[0, 0].Value);for (int i = 1; i < dgv.RowCount; i++)if (mayor < Convert.ToInt32(dgv[0, i].Value))Convert.ToInt32(dgv[0, i].Value);return mayor;public int Menor(DataGridView dgv)int menor = Convert.ToInt32(dgv[0, 0].Value);for (int i = 1; i < dgv.RowCount; i++)if (menor > Convert.ToInt32(dgv[0, i].Value))Convert.ToInt32(dgv[0, i].Value);return menor;
MessageBox.Show("Error! Matriz no apta para la suma de la Diagonal Invertida.");private void radioButton5_CheckedChanged(object sender, EventArgs e)Convert.ToString(mat.Menor(dgv1));private void radioButton4_CheckedChanged(object sender, EventArgs e)Convert.ToString(mat.Mayor(dgv1));private void Form1_Load(object sender, EventArgs e)