Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace full5
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Equacio A*x2 +B*x+C=0
- int a, b, c;
- double x1 = 0;
- double x2 = 0;
- Console.WriteLine("Posa un valor int per A:");
- a = Int32.Parse(Console.ReadLine());
- Console.WriteLine("Posa un valor int per B:");
- b = Int32.Parse(Console.ReadLine());
- Console.WriteLine("Posa un valor int per C:");
- c = Int32.Parse(Console.ReadLine());
- equacio(ref a,ref b,ref c,ref x1,ref x2);
- Console.WriteLine("Resultat de la equacio amb X1={0,5:f2}", x1);
- //x2 = equacio(a, b, c);
- Console.WriteLine("Resultat de la equacio amb X2={0,5:f2}", x2);
- Console.WriteLine("");
- Console.WriteLine("");
- equacio2(ref x1, ref x2);
- Console.WriteLine("Resultat de la equacio amb X1={0,5:f2}", x1);
- //x2 = equacio(a, b, c);
- Console.WriteLine("Resultat de la equacio amb X2={0,5:f2}", x2);
- Console.ReadLine();
- }
- static void equacio(ref int A,ref int B,ref int C,ref double x1,ref double x2)
- {
- //double x1= 0;
- // double x2 = 0;
- x1 = (-B + Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
- x2 = (-B - Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
- }
- static void equacio2(ref double x1, ref double x2)
- {
- int A = 1;
- int B = -5;
- int C = 6;
- x1 = (-B + Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
- x2 = (-B - Math.Sqrt(B * B - 4 * A * C)) / 2 * A;
- }
- }
- }
Add Comment
Please, Sign In to add comment