myGully.com Boerse.SH - BOERSE.AM - BOERSE.IO - BOERSE.IM Boerse.BZ .TO Nachfolger
Zurück   myGully.com > Computer & Technik > Programmierung
Seite neu laden

Wo ist der Fehler?

Willkommen

myGully

Links

Forum

 
 
 
Themen-Optionen Ansicht
Prev Vorheriger Beitrag   Nächster Beitrag Next
Ungelesen 10.09.10, 23:37   #2
urga
Mitglied
 
Benutzerbild von urga
 
Registriert seit: Aug 2009
Ort: void* (*wtf[])(void **);
Beiträge: 453
Bedankt: 137
urga ist noch neu hier! | 0 Respekt Punkte
Standard

ist ja ne super beschissene formatierung!
ich fang' mal damit an.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(int argc, char *argv[])
{
	char responseab, responseac, responsebc, responseah, responsebh, responsech;
	float a, a2, b, b2, c, c2, h, p, q;
	printf("Dreiecksberechner Ich rechne fuer sie die Seiten im rechtwinkligen Dreieck aus ^-^\nNote: a^2=c*p\n\n\n");
	printf("Wissen sie a und b? (j)a,(n)ein:");
	fflush(stdout);
	scanf("%c%*c",&responseab);
	if (responseab == 'j')

	{
		printf("\na:");
		scanf("%f",&a);
		printf("\nb:");
		scanf("%f",&b);
		fflush(stdin);
		c2=(a*a + b*b);
		c= sqrt(c2);
		p=(a*a)/c;
		q=c-p;
		h=p*q;
		printf("\nc:%f\np:%f\nq:%f\nh:%f\n",c,p,q,h);
	}
	if (responseab == 'n')
	{
		fflush(stdin);
		printf("\nWissen sie a und c? (j)a/(n)ein:");
		scanf("%c",&responseac);
		if (responseac == 'j')
		{
			printf("\na:");
			scanf("%f",&a);
			printf("\nc:");
			scanf("%f",&c);
			fflush(stdin);
			b2= c*c - a*a;
			b= sqrt(b2);
			p=(a*a)/c;
			q=c-p;
			h=p*q;
			printf("\nb:%f\np:%f\nq:%f\nh:%f \n",b,p,q,h);
		}

		if (responseac == 'n')
		{
			fflush(stdin);
			printf("\nWissen sie b und c? (j)a/(n)ein:");
			scanf("%c",&responsebc);
			if (responsebc == 'j')
			{
				printf("\nb:");
				scanf("%f",&b);
				printf("\nc:");
				scanf("%f",&c);
				fflush(stdin);
				a2= c*c - b*b;
				a= sqrt(a2);
				p=(a*a)/c;
				q=c-p;
				h=p*q;
				printf("\na:%f\np:%f\nq:%f\nh:%f \n",a,p,q,h);
				fflush(stdin);
			}
			if (responsebc == 'n')
			{
				fflush(stdin);
				printf("\nWissen sie a und h? (j)a/(n)ein:");
				scanf("%c",&responseah);
				if (responseah == 'j') /*Ab hier wird nicht mehr das Ergebnis angezeigt*/
				{
					printf("\na:");
					scanf("%f",&a);
					printf("\nh:");
					scanf("%f",&h);
					fflush(stdin);
					p= sqrt(a*a - h*h);
					fflush(stdin);
					c= (a*a)/p;
					fflush(stdin);
					q=c-p;
					fflush(stdin);
					b= sqrt(c*c - a*a);
					printf("\nb:%f\np:%f\nq:%f\nc:%f \n",b,p,q,c);
					fflush(stdin);
					goto ENDE;

				}
				if (responseah == 'n');
				{
					fflush(stdin);
					printf("\nWissen sie b und h? (j)a/(n)ein:");
					scanf("%c",&responsebh);
					if (responsebh == 'j'); /* Hier ist es egal, was ich nehme.
																	 *Ob 'j' oder 'n' es wird nach b und h gefragt
																	 *und dann setzt der goto-befehl ein
																	 *den ich gemacht habe, weil sonst die Frage nach c und h kommt*/
					{
						printf("\nb:");
						scanf("%f",&b);
						printf("\nh:");
						scanf("%f",&h);
						fflush(stdin);
						q= sqrt(b*b - h*h);
						fflush(stdin);
						c= (b*b)/q;
						fflush(stdin);
						p=c-q;
						fflush(stdin);
						a= sqrt(c*c - b*b);
						printf("\na:%f\np:%f\nq:%f\nc:%f \n",a,p,q,c);
						goto ENDE;

					}
					if (responsebh == 'n');
					{
						fflush(stdin);
						printf("\nWissen sie c und h? (j)a/(n)ein:");
						scanf("%c",&responsech);
						if (responsech == 'j')
						{
							printf("\nc:");
							scanf("%f",&c);
							printf("\nh:");
							scanf("%f",&h);
							fflush(stdin);
							q= c-(h/q);
							fflush(stdin);
							p= c-q;
							fflush(stdin);
							a= sqrt(c*p);
							fflush(stdin);
							b= sqrt(c*c - a*a);
							printf("\nb:%f\np:%f\nq:%f\na:%f \n",b,p,q,a);
							goto ENDE;
						}
						if (responsech == 'n')
						{
							printf("\nEs tut mir auserordentlich Leid\nIch weiß noch nicht, wie ich mit Winkeln umzugehen habe.\n");
						}
					}
				}
			}
		}
	}
ENDE : printf("\nIch hoffe ich habe ihnen geholfen und keine Fehler gemacht, wobei ich natuerlich NIE Fehler mache\n\nMit freundlichen Gruessen,\n Hans^-^\n");

			 system("PAUSE");
			 return 0;
}
ausserdem echt sehr bescheidener programmierstiel!
versuch' erstmal das programm in einzelnde funktionen zu zerlegen. da blickt ja keiner durch!

und, die ganzen fflush(stdin); kannst du dir komplett sparen. was wolltest du damit eigentlich erreichen?
__________________
entropie erfordert keine wartung
urga ist offline   Mit Zitat antworten
 


Forumregeln
Du kannst keine neue Themen eröffnen
Du kannst keine Antworten verfassen
Du kannst keine Anhänge posten
Du kannst nicht deine Beiträge editieren

BB code is An
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:37 Uhr.


Sitemap

().