Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo Leute, ich hab ein Programm geschrieben, (siehe 1. Programm)

und jetzt möchte ich dass das programm mit 2 funktionen läuft (max und mitte)

leider komme da fehler ich weiß nicht warum ...

1. Programm :

#include<iostream.h>

#include<stdlib.h>

void main(void)

{

int wahl;

do

{

float weite[5], mitte=0;

int max=0;

for (int i=0; i<5; i++)

{

do

{

cout << " Geben Sie den " << i+1 << " Wurf an: " << endl ;

cin >> weite;

if (weite<0)

cout << "Fehler! Der Wurf kann nicht kleiner als 0 sein\n";

}

while(weite<0);

}

for (int i=0; i<5; i++)

{

if (max<weite)

{

max=weite;

}

}

cout << " Der groesste Wurf lieft bei " << max << " Meter!\n";

for (int i=0; i<5; i++)

{

mitte=mitte+weite;

}

mitte=(mitte-max)/4;

cout << " Der Mittelwert der 4 kleineren Wurfweiten liegt bei " << mitte << " Meter!\n";

cout << endl;

cout << "Moechten Sie das Programm noch ein Mal durchfuehren? Bitte 1 drücken, sonst beliebige Taste\n";

cin >> wahl;

}

while(wahl==1);

}

-------

2 programm:

#include<iostream.h>

#include<stdlib.h>

float max(float *weite)

{

float fmax=0;

for (int i=0; i<5; i++)

{

do

{

cout << " Geben Sie den " << i+1 << " Wurf an: " << endl ;

cin >> weite;

if (weite<0)

cout << "Fehler! Der Wurf kann nicht kleiner als 0 sein\n";

}

while(weite<0);

for (int i=0; i<5; i++)

{

if (fmax<weite)

{

fmax=weite;

}

}

return fmax;

}

void mitte(float max, float *weite)

{

float fmitte;

for (int i=0; i<5; i++)

{

fmitte=fmitte+weite;

}

fmitte=(fmitte-max)/4;

cout << " Der durchschnitt der 4 niedrigsten liegt bei " << fmitte << " Meter!\n";

}

void main(void)

{

do

{

int wahl;

float mainweite[5], mainmitte, mainmax;

mainmax = max(mainweite);

cout << " Der groesste Wurf lieft bei " << mainmax << " Meter!\n";

mitte(mainmax, mainweite);

cout << "Moechten Sie das Programm noch ein Mal durchfuehren? Bitte 1 drücken, sonst beliebige Taste\n";

cin >> wahl;

}

while(wahl==1);

}

  • Autor

#include<iostream.h>

#include<stdlib.h>

float max(float *weite)

{

float fmax=0;

for (int i=0; i<5; i++)

{

do

{

cout << " Geben Sie den " << i+1 << " Wurf an: " << endl ;

cin >> weite;

if (weite<0)

cout << "Fehler! Der Wurf kann nicht kleiner als 0 sein\n";

}

while(weite<0);

for (int i=0; i<5; i++)

{

if (fmax<weite)

{

fmax=weite;

}

}

return fmax;

}

void mitte(float max, float *weite)

{ // parse error before `{'

float fmitte;

for (int i=0; i<5; i++)

{

fmitte=fmitte+weite; `fmitte' undeclared (first use this function)

}

fmitte=(fmitte-max)/4;

cout << " Der durchschnitt der 4 niedrigsten liegt bei " << fmitte << " Meter!\n";

}

void main(void)

{

do

{

int wahl;

float mainweite[5], mainmitte, mainmax;

mainmax = max(mainweite);

cout << " Der groesste Wurf lieft bei " << mainmax << " Meter!\n";

mitte(mainmax, mainweite); implicit declaration of function `int mitte(...)'

cout << "Moechten Sie das Programm noch ein Mal durchfuehren? Bitte 1 drücken, sonst beliebige Taste\n";

cin >> wahl;

}

while(wahl==1); `wahl' undeclared (first use this function)

}

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.