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.

Freier Parkplatz Aufgabe, Wo liegt der Fehler?

Empfohlene Antworten

Veröffentlicht

Hi,

folgende Situation:

Es ist ein Parkplatz frei und zwar Stock 2 Platz 8, diesen soll er am Ende auch rausgeben. Das Problem er gibt irgendwas anderes aus und ich weis nicht genau wo er die Werte nimmt. An sich keine große Sache 2 Schleifen.. vielleicht habe ich irgend nen Gedankenfehler oder sowas.

Wäre nett, wenn mit jemand auf die Sprünge helfen könnte.


#include<iostream.h>



int main()

    {


    bool ab_Parkhaus[2][9];



    ab_Parkhaus[2][9]=0;

    ab_Parkhaus[2][8]=1;

    ab_Parkhaus[2][7]=0;

    ab_Parkhaus[2][6]=0;

    ab_Parkhaus[2][5]=0;

    ab_Parkhaus[2][4]=0;

    ab_Parkhaus[2][3]=0;

    ab_Parkhaus[2][2]=0;

    ab_Parkhaus[2][1]=0;

    ab_Parkhaus[2][0]=0;





    //Etage


    int iEtage;

    bool bFrei;


       int i=2;

       int j=0;



         for(;i>=0;i--)

           {

           //cout<<"i"<<i;

           getchar();

           j = 0;

           for(;j<=9;j++)

             {

             ab_Parkhaus[2][8]=1;

             cout<<"i"<<i<<"\t";

             cout<<"j"<<j;

             getchar();


             if(ab_Parkhaus[i][j]==1)

               {

               cout<<"Parkplatz frei";

                   bFrei=true;

                   //getchar();

                   //return 1;


               }

             else

                 {

                 cout<<"Parkplatz Besetz";

                 //funktion Ausfahrt!!

                 }


             }

           }


       cout<<"i"<<i<<"j"<<j;


    getchar();

    }


Das Problem er gibt irgendwas anderes aus... :rolleyes:

Dein Quellcode ist furchbar zu lesen.

Mach dir bitte ein Struktogramm für diese Aufgabe und spiel sie mal durch.

bool ab_Parkhaus[2][9];
Dein Parkhaus ist nicht so groß wie du glaubst, nämlich nur 2 mal 9 Plätze. Der gültige Index für die erste Dimension geht von 0 bis 1, der für die zweite von 0 bis 8. Alle deine Zuweisungen mit ab_Parkhaus[2] sind damit schon mal falsch.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.