I'm trying to Write a program, to allow users to Enter Student Records into an Array and means of Selection Sort from the Array. I am trying to sort by the Student Number.
template <class dType>
void selectsort(dType temp[], int n)
{
int j = 0, k = 0, small;
if (n > 1)
for (k = 0; k < n - 1; k++)
{
small = k;
for (j = k + 1; j < n; j++)
if (temp[j] < temp[small]) small = j;
if (k != small) swaparr(temp[k], temp[small]);
}
}
struct student
{
int student_number; // Student number of student
string studnetname; // Name of student
string Address; //Address of Studnet
int CourseCode ; //Course Code
string CourseName; // Name of Course
}record[N_STUDENT];
should be
1 2 3 4 5 6 7 8
struct student
{
int student_number; // Student number of student
string studnetname; // Name of student
string Address; //Address of Studnet
int CourseCode ; //Course Code
string CourseName; // Name of Course
};
inside main....
1 2 3 4 5 6 7
int main ()
{
student record[N_STUDENT];
string mysrt; //remove this
string mysrt1;//remove this
int n;
selectSort(n < N_STUDENT);
for(n= 0; n < N_STUDENT; n++)
cout << "X at pos" << student[n] << endl;
at the end of the main,
cout << "X at pos" << student[n] << endl;
should be allowing me to give out the Sorted Student ID.
When i had
cout << "Enter Course Code: ";
cin >> record[n].CourseCode;
Xcode was giving me errors since that was an int. so i had to use
getline (cin, mysrt1);
which seem to work but not was not declared in the array