Write a C++ program that prints the attendance sheet of students in a class ordered by either their names or by their ID’s. The instructor will enter the number of students in the class; the students’ names [First Last] and their ID’s which will be entered as integers, and then save them in a file called “Sheet.txt”.
Then the program should ask the user about his/her choice for the sorting of the sheet according to names or ID’s. The sorted sheet should be saved in a file called “Sorted.txt”.
You are required to use structure for the student and to sort the sheet using bubble sort with pointers.
please help!!!!
#include "stdafx.h"
#include<iostream>
using namespace std;
#define s 10
void bubblesort(int*,int );
void swap(int*,int* );
int _tmain(int argc, _TCHAR* argv[])
{
int a[s]={2,4,8,20,10,90,89,70,1,3};
cout<<"print original: ";
for (int i=0;i<s;i++)
{
cout<<a[i]<<'\t';
}
cout<<endl;
bubblesort(a,s);
for (int i=0;i<s;i++)
{
cout<<a[i]<<'\t';
}
cout<<endl;
return 0;
}
//---------------------------------------------
void bubblesort(int* arr,int j)
{
for (int i=0;i<j;i++)
for (int p=0;p<j;p++)
if (arr[p]>arr[p+1])
{
swap(&arr[p],&arr[p+1]);
}
}