Ja, genau so hab ich's gemeint...
Ich habs nur auskommentiert weil ich nicht wusste wie ich das anwenden sollte, naja trotzdem hab ich's hingekriegt.
Naja aber ohne Zeiger halt...
Code:
#include<iostream.h>
void bubble(int iArray[][2], int);
int main()
{
int x;
cout<<"Anzahl der Studenten:"<<" ";
cin>>x; //xAnzahl der Studenten
int mat[x][2], temp; //2 Spalten
char name[x][100]; //name bis 100 Zeichen lang
for(int j=0; j<x; j++){
cout<<"Geben Sie die Matnr ein:"<<" ";
cin>>mat[j][0]; //Eingabe der matnr und name in den Feldern
mat[j][1]=j;
cout<<"Geben Sie den Namen ein:"<<" ";
cin>>name[j];
}
bubble(mat,x); //bubble Aufruf
for (int j=0; j<x; j++)
{
cout << mat[j][0] <<" ";
temp=mat[j][1];
cout << name[temp] << endl;
}
}
void bubble(int iArray[][2], int x) { //bubble sort Funktion
for(int i = 0; i < x; i++) {
for(int j = 0; j < (x - 1); j++) {
if(iArray[j][0] > iArray[j + 1][0]) {
int iTemp = iArray[j][0];
iArray[j][0] = iArray[j + 1][0];
iArray[j + 1][0] = iTemp;
iTemp = iArray[j][1];
iArray[j][1] = iArray[j + 1][1];
iArray[j + 1][1] = iTemp;
}
}
}
}