Zu diesem Thema habe ich folgendes kleine aber feine C-Programm:
Code:
#include <stdio.h>
#include <conio.h>
void main ()
{
int a, b, c, stat;
stat = 0;
clrscr ( );
while (stat != -1)
{
printf ("Bitte die 3 Seiten des Dreiecks eingeben.\n");
printf ("Seite a: ");
printf ("");
stat = scanf ("%d", &a);
printf ("Seite b: ");
printf ("");
stat = scanf ("%d", &b);
printf ("Seite c: ");
printf ("");
stat = scanf ("%d", &c);
if (((a + b) <= c) || ((b + c) <= a) || ((a + c) <= b))
{
printf ("kein Dreieck!\n\n");
stat = getch ();
}
else
{
if ((a == b) && (a == c))
{
printf ("gleichseitiges Dreieck\n\n");
stat = getch ();
}
else
{
if ((a == b) || (a == c) || (b == c))
{
if (((a * a) + (b * b) == (c * c)) ||
((b * b) + (c * c) == (a * a)) ||
((c * c) + (a * a) == (b * b)))
{
printf ("gleichschenkeliges rechtwinkeliges Dreieck\n\n");
stat = getch ();
}
else
{
printf ("gleichschenkeliges Dreieck\n\n");
stat = getch ();
}
}
else
{
if (((a * a) + (b * b) == (c * c)) ||
((b * b) + (c * c) == (a * a)) ||
((c * c) + (a * a) == (b * b)))
{
printf ("rechtwinkeliges Dreieck\n\n");
stat = getch ();
}
else
{
printf ("allgemeines Dreieck\n\n");
stat = getch ();
}
}
}
}
}
}