blob: 1d09e173160f8f90a800f0cd3d4a1ebb116ccebb (
plain)
1
2
3
4
5
6
7
8
9
10
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
|
import java.util.Scanner;
public class Dreieck
{
public static void main(String[] args)
{
Scanner mys = new Scanner(System.in);
int a,b,c;
do
{
System.out.println("Bitte Seitenlaengen eingeben:");
a = mys.nextInt();
b = mys.nextInt();
c = mys.nextInt();
System.out.println(getType(a, b, c));
}while(true);
}
public static String getType(int a, int b, int c)
{
// berechne groesste, mittlere kleinste Seite
// größte Seite ist größer als die Summe der beiden anderen
int min, mid, max;
if(a > b)
{
mid = a;
min = b;
}
else
{
mid = b;
min = a;
}
if(c > mid)
{
max = c;
}
else if(c > min)
{
max = mid;
mid = c;
}
else
{
max = mid;
mid = min;
min = c;
}
if(max>min+mid || max==0) // es müsste richtig heißen: || min==0
{
return "Kein Dreieck";
}
if(max*max-min*min-mid*mid==0)
{
return "Rechtwinkliges Dreieck";
}
if(min == max)
{
return "Gleichseitiges Dreieck";
}
else if((max==mid)||(mid==min))
{
return "Gleichschenkliges Dreieck";
}
return "Beliebiges Dreieck";
}
}
|