hallo, ik heb zelf een probleempje.
Ik kan de fout in dit programmatje maar niet vinden, iemand?
#include <y:\vcpp\header.h>
int nr[10],dw1[10],dw2[10],dw3[10],tot[10];
int menu()
{
int keuze;
titelscherm("MENU STUDENTEN GEGEVENS");
gotoxy(5,5);cout<<"1. Invoer studentennummers en initialisatie";
gotoxy(5,6);cout<<"2. Invoer punten DW1, DW2 en DW3";
gotoxy(5,7);cout<<"3. Berekening totaal, sorteren en afdruk gegevens";
gotoxy(5,9);cout<<"0. Stoppen";
gotoxy(5,11);cout<<"Uw keuze : ";
cin>>keuze;
return(keuze);
}
int invoer_studentnrs()
{
int i,aantal;
titelscherm("INVOER STUDENTEN NR'S");
i=0;
gotoxy(5,5);cout<<"Geef studentnr (0=stop) : ";
cin>>nr;
while(nr!=0 && i<9)
{
i++;
gotoxy(5,5+i);cout<<"Geef studentnr (0=stop) : ";
cin>>nr;
}
if(nr==0)
{
aantal=i;
}
else
{
aantal=10;
}
return(aantal);
}
void initialiseren(int aantal)
{
int i;
for(i=0;i<aantal;i++)
{
dw1=0;
dw2=0;
dw3=0;
tot=0;
}
}
void invoerpunten(int aantal)
{
int i;
titelscherm("INVOER PUNTEN");
gotoxy(10,5);cout<<"DW1";
gotoxy(20,5);cout<<"DW2";
gotoxy(30,5);cout<<"DW3";
for(i=0;i<aantal;i++)
{
gotoxy(10,6+i);cin>>dw1;
gotoxy(20,6+i);cin>>dw2;
gotoxy(30,6+i);cin>>dw3;
}
}
void ber_tot(int aantal)
{
int i;
for(i=0;i<aantal;i++)
{
tot=dw1+dw2+dw3;
}
}
void sorteren(int aantal)
{
int i,j,hulp;
for(i=0;i<aantal-1;i++)
{
for(j=i+1;j<aantal;j++)
{
if(tot<tot[j])
{
hulp=tot;
tot=tot[j];
tot[j]=hulp;
hulp=nr;
nr=nr[j];
nr[j]=hulp;
hulp=dw1;
dw1=dw1[j];
dw1[j]=hulp;
hulp=dw2;
dw2=dw2[j];
dw2[j]=hulp;
hulp=dw3;
dw3=dw3[j];
dw3[j]=hulp;
}
}
}
}
void afdruk_geg(int aantal)
{
int i;
titelscherm("UITVOER PUNTEN");
gotoxy(10,5);cout<<"DW1";
gotoxy(20,5);cout<<"DW2";
gotoxy(30,5);cout<<"DW3";
gotoxy(40,5);cout<<"TOTAAL";
for(i=0;i<aantal;i++)
{
gotoxy(10,6+i);cout<<dw1;
gotoxy(20,6+i);cout<<dw2;
gotoxy(30,6+i);cout<<dw3;
gotoxy(44,6+i);cout<<tot;
}
}
void main()
{
int keuze,aantal;
keuze=menu();
while(keuze!=0)
{
switch(keuze)
{
case 1:
aantal=invoer_studentnrs();
initialiseren(aantal);
break;
case 2:
invoerpunten(aantal);
break;
case 3:
ber_tot(aantal);
sorteren(aantal);
afdruk_geg(aantal);
break;
}
keuze=menu();
}
}