Advertisement
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;
- using System.Threading.Tasks;
- namespace Dreieckberechnung
- {
- class Program
- {
- static void Main(string[] args)
- {
- double a = 0;
- double b = 0;
- double c = 0;
- Console.WriteLine("DREIECKSBERECHNER!");
- Console.WriteLine("Hier kannst du Berechnen, ob ein Dreieck rechtwinkelig, gleichschenkelig, gleichseitig oder allgemein ist.");
- Console.WriteLine("Gib die 1. Seite des Dreiecks an!(m)");
- a = double.Parse(Console.ReadLine());
- Console.WriteLine("Gib die 2. Seite des Dreiecks an!(m)");
- b = double.Parse(Console.ReadLine());
- Console.WriteLine("Gib die 3. Seite des Dreiecks an!(m)");
- c = double.Parse(Console.ReadLine());
- if (a > 0 && b > 0 && c > 0)
- {
- double[] array = new double[] { a, b, c };
- double findmax = 0;
- foreach (double item in array)
- {
- if (item > findmax)
- {
- findmax = item;
- }
- }
- if (findmax == a && a >= b + c || findmax == b && b >= a + c || findmax == c && c >= a + b)
- {
- double cos1 = 0;
- double cos2 = 0;
- double cos3 = 0;
- Math.Cos(cos1) = (Math.Pow(b, 2) + Math.Pow(c, 2) - Math.Pow(a, 2))/ 2 * b * c;
- if (cos1 + cos2 + cos3 = 180)
- {
- if (Math.Pow(a, 2) * Math.Pow(b, 2) == Math.Pow(c, 2) || Math.Pow(a, 2) * Math.Pow(c, 2) == Math.Pow(c, 2) || Math.Pow(a, 2) == Math.Pow(c, 2) * Math.Pow(b, 2))
- {
- Console.WriteLine("Es handelt sich um ein Rechtwinkeliges Dreieck");
- }
- else if (a == b || b == c || a == c)
- {
- Console.WriteLine("Es handelt sich um ein Gleichschenkeliges Dreieck");
- }
- else if (a == b && b == c)
- {
- Console.WriteLine("Es handelt sich um ein Gleichseitiges Dreieck");
- }
- else
- {
- Console.WriteLine("Es handelt sich um ein Gleichschenkeliges Dreieck");
- }
- }
- else
- {
- Console.WriteLine("Die angegebenen Seiten können kein Dreieck ergeben!");
- }
- }
- else
- {
- Console.WriteLine("Ungültige Eingabe! Summe der Kürzesten Seiten ist kleiner gleich der Längsten Seite");
- }
- }
- else
- {
- Console.WriteLine("Ungültige Eingabe");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement