Hallo, dit is de code die ik tot nu toe al heb:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
struct SPunt2D
{
int iX;
int iY;
};
struct SPunt2DTabel
{
int iX_Een, iX_Twee, iX_Drie, iX_Vier, iX_Vijf;
int iY_Een, iY_Twee, iY_Drie, iY_Vier, iY_Vijf;
};
void vFLees( SPunt2D& oPunt );
void vFPrint( const SPunt2D& oPunt );
void vFLees( SPunt2DTabel& oTabel );
void vFPrint( const SPunt2DTabel& oTabel );
int main()
{
SPunt2D oPunt;
cout << "Geef de coordinaten van het punt in: " << endl;
vFLees( oPunt );
cout << "De ingevoerde gegevens zijn: " << endl;
vFPrint( oPunt );
SPunt2D oTabel;
cout << "Geef 5 koppels coordinaten in: " << endl;
vFLees( oTabel );
cout << "De ingegeven koppels zijn: " << endl;
vFPrint( oTabel );
}
void vFLees( SPunt2D& oPunt )
{
cin >> oPunt.iX >> oPunt.iY;
flushall();
}
void vFPrint( const SPunt2D& oPunt )
{
cout << "De ingegeven X-coordinaat is: " << oPunt.iX << endl;
cout << "De ingegeven Y-coordinaat is: " << oPunt.iY << endl;
}
void vFLees( SPunt2DTabel& oTabel )
{
cin >> oTabel.iX_Een >> oTabel.iY_Een >>
oTabel.iX_Twee >> oTabel.iY_Twee >>
oTabel.iX_Drie >> oTabel.iY_Drie >>
oTabel.iX_Vier >> oTabel.iY_Vier >>
oTabel.iX_Vijf >> oTabel.iY_Vijf;
}
void vFPrint( const SPunt2DTabel& oTabel )
{
cout << setw(15) << "De ingegeven koppels zijn" << endl;
cout << "=========================" << endl << endl;
cout << "X-coordinaat" << setw(15) <<"Y-coordinaat" << endl;
cout << "============" << setw(15) << "===========" << endl;
cout << oTabel.iX_Een << setw(15) << oTabel.iY_Een << endl;
cout << oTabel.iX_Twee << setw(15) << oTabel.iY_Twee << endl;
cout << oTabel.iX_Drie << setw(15) << oTabel.iY_Drie << endl;
cout << oTabel.iX_Vier << setw(15) << oTabel.iY_Vier << endl;
cout << oTabel.iX_Vijf << setw(15) << oTabel.iY_Vijf << endl;
}
Ik heb 2 structures gedeclareerd (SPunt2D en SPunt2DTabel). Nu wordt er gevraagd om 5 koppels (X en Y) in een tabel af te drukken. De functie die dit hoort te doen is vFPrint( const SPunt2DTabel& oTabel). Als je het programma runt zie je dat ik telkens 2 keer hetzelfde op mn scherm krijg. Kan iemand mij helpen om een tabel af te drukken ?
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
struct SPunt2D
{
int iX;
int iY;
};
struct SPunt2DTabel
{
int iX_Een, iX_Twee, iX_Drie, iX_Vier, iX_Vijf;
int iY_Een, iY_Twee, iY_Drie, iY_Vier, iY_Vijf;
};
void vFLees( SPunt2D& oPunt );
void vFPrint( const SPunt2D& oPunt );
void vFLees( SPunt2DTabel& oTabel );
void vFPrint( const SPunt2DTabel& oTabel );
int main()
{
SPunt2D oPunt;
cout << "Geef de coordinaten van het punt in: " << endl;
vFLees( oPunt );
cout << "De ingevoerde gegevens zijn: " << endl;
vFPrint( oPunt );
SPunt2D oTabel;
cout << "Geef 5 koppels coordinaten in: " << endl;
vFLees( oTabel );
cout << "De ingegeven koppels zijn: " << endl;
vFPrint( oTabel );
}
void vFLees( SPunt2D& oPunt )
{
cin >> oPunt.iX >> oPunt.iY;
flushall();
}
void vFPrint( const SPunt2D& oPunt )
{
cout << "De ingegeven X-coordinaat is: " << oPunt.iX << endl;
cout << "De ingegeven Y-coordinaat is: " << oPunt.iY << endl;
}
void vFLees( SPunt2DTabel& oTabel )
{
cin >> oTabel.iX_Een >> oTabel.iY_Een >>
oTabel.iX_Twee >> oTabel.iY_Twee >>
oTabel.iX_Drie >> oTabel.iY_Drie >>
oTabel.iX_Vier >> oTabel.iY_Vier >>
oTabel.iX_Vijf >> oTabel.iY_Vijf;
}
void vFPrint( const SPunt2DTabel& oTabel )
{
cout << setw(15) << "De ingegeven koppels zijn" << endl;
cout << "=========================" << endl << endl;
cout << "X-coordinaat" << setw(15) <<"Y-coordinaat" << endl;
cout << "============" << setw(15) << "===========" << endl;
cout << oTabel.iX_Een << setw(15) << oTabel.iY_Een << endl;
cout << oTabel.iX_Twee << setw(15) << oTabel.iY_Twee << endl;
cout << oTabel.iX_Drie << setw(15) << oTabel.iY_Drie << endl;
cout << oTabel.iX_Vier << setw(15) << oTabel.iY_Vier << endl;
cout << oTabel.iX_Vijf << setw(15) << oTabel.iY_Vijf << endl;
}
Ik heb 2 structures gedeclareerd (SPunt2D en SPunt2DTabel). Nu wordt er gevraagd om 5 koppels (X en Y) in een tabel af te drukken. De functie die dit hoort te doen is vFPrint( const SPunt2DTabel& oTabel). Als je het programma runt zie je dat ik telkens 2 keer hetzelfde op mn scherm krijg. Kan iemand mij helpen om een tabel af te drukken ?