static void Main(string[] args) { string inp; double a, b, c, bac, R1, R2; inp = Console.ReadLine(); string[] inpArr = inp.Split(' '); a = Convert.ToDouble(inpArr[0]); b = Convert.ToDouble(inpArr[1]); c = Convert.ToDouble(inpArr[2]); bac = Math.Pow(b, 2) - 4 * a * c; if (bac < 0 || (2 * a) == 0) { Console.WriteLine("Impossivel calcular"); } else { R1 = (-b + Math.Sqrt(bac)) / (2 * a); R2 = (-b - Math.Sqrt(bac)) / (2 * a); Console.WriteLine("R1 = " + R1.ToString("f5")); Console.WriteLine("R2 = " + R2.ToString("f5")); } Console.ReadKey(); }
static void Main(string[] args) { double x, y, z; double R1, R2, Delta; string[] N; N = Console.ReadLine().Split(' '); x = Convert.ToDouble(N[0]); y = Convert.ToDouble(N[1]); z = Convert.ToDouble(N[2]); Delta = ((y * y) - (4 * x * z)); if ((Delta < 0) || (x == 0)) { Console.WriteLine("Impossivel Calcular"); } else { R1 = ((-y + Math.Sqrt(Delta)) / (2 * x)); R2 = ((-y - Math.Sqrt(Delta)) / (2 * x)); Console.WriteLine("R1 = " + R1.ToString("F5")); Console.WriteLine("R2 = " + R2.ToString("F5")); } }
private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { // Muestra los numeros de RGB de un pixel seleccionado por el mouse int R2, G2, B2; R2 = 0; G2 = 0; B2 = 0; Color c = new Color(); for (int i = e.X; i < e.X + 5; i++) { for (int j = e.Y; j < e.Y + 5; j++) { c = bmp.GetPixel(i, j); R2 = R2 + c.R; G2 = G2 + c.G; B2 = B2 + c.B; } } R2 = R2 / 25; G2 = G2 / 25; B2 = B2 / 25; textBox1.Text = R2.ToString(); textBox2.Text = G2.ToString(); textBox3.Text = B2.ToString(); // Modificamos el valor rgb seleccionado por el mouse el promedio de los 5pixeles a su alrededor c1 = Color.FromArgb(R2, G2, B2); //textBox4.BackColor=c; }
static void Uri1036(string[] args) { double A, B, C; double R1, R2, Delta; string[] N; N = Console.ReadLine().Split(' '); A = Convert.ToDouble(N[0]); B = Convert.ToDouble(N[1]); C = Convert.ToDouble(N[2]); Delta = ((B * B) - (4 * A * C)); if ((Delta < 0) || (A == 0)) { Console.WriteLine("Impossivel Calcular"); } else { R1 = ((-B + Math.Sqrt(Delta)) / (2 * A)); R2 = ((-B - Math.Sqrt(Delta)) / (2 * A)); Console.WriteLine("R1 = " + R1.ToString("F5")); Console.WriteLine("R2 = " + R2.ToString("F5")); } }
static void Main(string[] args) { double A, B, C, Delta, R1, R2; String[] vet = Console.ReadLine().Split(' '); A = double.Parse(vet[0], CultureInfo.InvariantCulture); B = double.Parse(vet[1], CultureInfo.InvariantCulture); C = double.Parse(vet[2], CultureInfo.InvariantCulture); Delta = Math.Pow(B, 2.0) - 4 * A * C; if (A == 0 || Delta < 0.0) { Console.WriteLine("Impossível Calcular"); } else { R1 = (-B + Math.Sqrt(Delta)) / (2.0 * A); R2 = (-B - Math.Sqrt(Delta)) / (2.0 * A); Console.WriteLine("R1 = " + R1.ToString("F5", CultureInfo.InvariantCulture)); Console.WriteLine("R2 = " + R2.ToString("F5", CultureInfo.InvariantCulture)); } }
public override string ToString() { return(string.Format("{{ {0}, {1}, {2}, {3} }}", R0.ToString(), R1.ToString(), R2.ToString(), R3.ToString())); }
public XElement ToXml() { return(new XElement(this.GetType().ToString(), new XAttribute("Enabled", Enabled.ToString(CultureInfo.InvariantCulture)), new XAttribute("R1", R1.ToString(CultureInfo.InvariantCulture)), new XAttribute("R2", R2.ToString(CultureInfo.InvariantCulture)), new XAttribute("F", F.ToString(CultureInfo.InvariantCulture)) )); }
void ReadSystemParam() { double x; NiuJuPID.pgain = double.Parse(iniFileOP.Read("System Setting", "NiuJu_pgain")); NiuJuPID.igain = double.Parse(iniFileOP.Read("System Setting", "NiuJu_igain")); NiuJuPID.dgain = double.Parse(iniFileOP.Read("System Setting", "NiuJu_dgain")); deweNiuJu_k = double.Parse(iniFileOP.Read("System Setting", "deweNiuJu_k")); deweNiuJu_b = double.Parse(iniFileOP.Read("System Setting", "deweNiuJu_b")); deweNiuZhen_k = double.Parse(iniFileOP.Read("System Setting", "deweNiuZhen_k")); deweNiuZhen_b = double.Parse(iniFileOP.Read("System Setting", "deweNiuZhen_b")); NiuZhenPID.sp = double.Parse(iniFileOP.Read("System Setting", "NiuZhen_sp")); NiuJuPID.sp = double.Parse(iniFileOP.Read("System Setting", "NiuJu_sp")); R2 = (_R2)int.Parse(iniFileOP.Read("System Setting", "R2")); x = double.Parse(iniFileOP.Read("System Setting", "NiuZhen_Deadband")); NiuZhenPID.deadband = x * NiuZhenPID.sp; x = double.Parse(iniFileOP.Read("System Setting", "NiuJu_Deadband")); NiuJuPID.deadband = x * NiuJuPID.sp; NiuZhenPID.pgain = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_pgain")); NiuZhenPID.igain = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_igain")); NiuZhenPID.dgain = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_dgain")); double a, b, c; a = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_a")); b = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_b")); c = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_c")); openRev = a * NiuZhenPID.sp * NiuZhenPID.sp + b * NiuZhenPID.sp + c; openRev = openRev * 7; AllTime1 = int.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_AllTime1")); AllTime2 = int.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_AllTime2")); OpenTime = int.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_OpenTime")); openTimesCount = OpenTime / openTimer.Interval; listView1.Items[0].SubItems[1].Text = NiuZhenPID.sp.ToString(); listView1.Items[3].SubItems[1].Text = NiuZhenPID.pgain.ToString(); listView1.Items[4].SubItems[1].Text = NiuZhenPID.igain.ToString(); listView1.Items[5].SubItems[1].Text = NiuZhenPID.dgain.ToString(); listView1.Columns[1].Width = listView1.ClientSize.Width - listView1.Columns[0].Width; listView2.Items[0].SubItems[1].Text = NiuJuPID.sp.ToString(); listView2.Items[3].SubItems[1].Text = NiuJuPID.pgain.ToString(); listView2.Items[4].SubItems[1].Text = NiuJuPID.igain.ToString(); listView2.Items[5].SubItems[1].Text = NiuJuPID.dgain.ToString(); listView2.Columns[1].Width = listView2.ClientSize.Width - listView2.Columns[0].Width;// - listView1.Columns[1].Width; }
private void label1_Click(object sender, EventArgs e) { PIDSettingForm f = new PIDSettingForm(1, NiuZhenPID, R2); if (f.ShowDialog() == DialogResult.OK) { NiuZhenPID.pgain = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_pgain")); NiuZhenPID.igain = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_igain")); NiuZhenPID.dgain = double.Parse(iniFileOP.Read(R2.ToString(), R2.ToString() + "_dgain")); listView1.Items[3].SubItems[1].Text = NiuZhenPID.pgain.ToString(); listView1.Items[4].SubItems[1].Text = NiuZhenPID.igain.ToString(); listView1.Items[5].SubItems[1].Text = NiuZhenPID.dgain.ToString(); listView1.Columns[1].Width = listView1.ClientSize.Width - listView1.Columns[0].Width;// - listView1.Columns[1].Width; } }
static void Main(string[] args) { double A, B, C, delta, R1, R2; string[] vs = Console.ReadLine().Split(' '); A = double.Parse(vs[0], CultureInfo.InvariantCulture); B = double.Parse(vs[1], CultureInfo.InvariantCulture); C = double.Parse(vs[2], CultureInfo.InvariantCulture); delta = Math.Pow(B, 2) - 4 * A * C; if (A == 0 || delta < 0) { Console.WriteLine("Impossivel calcular"); } else { R1 = (-B + Math.Sqrt(delta)) / (2 * A); R2 = (-B - Math.Sqrt(delta)) / (2 * A); Console.WriteLine("R1 = " + R1.ToString("F5"), CultureInfo.InvariantCulture); Console.WriteLine("R2 = " + R2.ToString("F5"), CultureInfo.InvariantCulture); } }