Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include "fhswf_service.h"
- #include<string.h>
- #include<stdlib.h>
- #include<ctype.h>
- #include<math.h>
- int check_Input_float(char* eingabe);
- int main(void)
- {
- char vEingabe[10] = {0};
- char wEingabe[10] = {0};
- char xEingabe[10] = {0};
- char yEingabe[10] = {0};
- char dxEingabe[10] = {0};
- float v = 0.0, w = 0.0, dx = 0.0, punkt = 0.0, flaecheNeu = 0.0, flaecheAlt = 0.0, p = 0.0, xAlt = 0.0, yAlt = 0.0, xNeu = 0.0, yNeu = 0.0;
- float laengeVW = 0.0;
- int laenge = 0, fehler = 0;
- printf("Moin,Servus,Moin Herr Neugebauer oder Herr Klein #Ehregenommen");
- do {
- printf("\nBitte einen Wert fuer X eingeben: ");
- gets_s(xEingabe);
- } while (check_Input_float(xEingabe) == 0);
- xAlt = atof(xEingabe);
- do {
- do {
- printf("\nBitte einen Wert fuer Y eingeben: ");
- gets_s(yEingabe);
- } while (check_Input_float(yEingabe) == 0);
- } while (xEingabe <= yEingabe);
- yAlt = atof(yEingabe);
- do {
- printf("\nBitte einen Wert fuer V eingeben: ");
- gets_s(vEingabe);
- } while (check_Input_float(vEingabe) == 0);
- v = atof(vEingabe);
- do {
- printf("\nBitte einen Wert fuer W eingeben: ");
- gets_s(wEingabe);
- } while (check_Input_float(wEingabe) == 0);
- w = atof(wEingabe);
- do {
- printf("\nBitte einen Wert fuer die Schrittweite eingeben: ");
- gets_s(dxEingabe);
- } while (check_Input_float(dxEingabe) == 0);
- dx = atof(dxEingabe);
- laengeVW = sqrt(pow(v, 2) + pow(w, 2));
- yNeu = yAlt - w;
- p = dx;
- for (punkt =yNeu; punkt <= yAlt; punkt + p)
- {
- flaecheNeu = xNeu * yNeu;
- flaecheAlt = flaecheNeu;
- xNeu = xAlt - punkt;
- yNeu = yNeu + punkt;
- if (flaecheAlt <= flaecheNeu && xNeu > xAlt - v && yNeu < yAlt)
- {
- printf("\n\nDas Maximum liegt bei: x= %f y =%f", xNeu, yNeu);
- printf("\n\nDie maximale Flaeche betraegt :%f", flaecheAlt);
- }
- }
- printf("\n\nDas Maximum liegt bei: x= %f y =%f", xNeu, yNeu);
- printf("\n\nDie maximale Flaeche betraegt :%f", flaecheAlt);
- getchar();
- return(1);
- }
- /*Funktion zur Überprüfung einer korrekten Eingabe
- Rückgabewert 1 = korrekte Eingabe
- Rückgabewert 0 = unkorrekte Eingabe
- Prüfung von Vorzeichen
- Prüfung von Punkten
- */
- int check_Input_float(char* eingabe)
- {
- int index = 0;
- if (strlen(eingabe) == 0)
- {
- return(0);
- }
- if (eingabe[0]=='+')
- {
- eingabe[0] = '0';
- }
- else if (eingabe[0] == '-')
- {
- index = 1;
- }
- for (index; index < strlen(eingabe); index++)
- {
- if (!(isdigit(eingabe[index]) || eingabe[index]=='.'))
- {
- return(0);
- }
- }
- return(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement