1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include "stdafx.h"
using namespace std;
const int NUM_SCORES = 6;
typedef struct
{
int day;
int month;
int year;
} Date;
struct Student
{
int number;
Date dob;
float scores[NUM_SCORES];
} ;
Student studentsList[15];
Date date [15];
int entries;
int counter1=0, counter2=0, counter3=0;
void readStudent (Student student[], int &entries);
void BinarySearch (Student list[], int& item, bool& found);
int ForgetfulBinarySearch (Student list[], int& item, bool& found);
int REBinarySearch (Student list[], int& item, bool& found);
int _tmain(int argc, _TCHAR* argv[])
{
readStudent (studentsList, entries);
bool found = false;
char response;
do
{
for (int i=0; i < entries; i++)
{
cout << "Enter a Student number: " << endl;
cin >> studentsList[i].number;
BinarySearch(studentsList, studentsList[i].number, found);
ForgetfulBinarySearch(studentsList, studentsList[i].number, found);
REBinarySearch(studentsList, studentsList[i].number, found);
cout << "DOB: "<< studentsList[i].dob.day << "/" << studentsList[i].dob.month << "/" << studentsList[i].dob.year << endl;
cout << "Exam Results: "<< studentsList[i].scores[0] << " " << studentsList[i].scores[1] << " " << studentsList[i].scores[2]
<< " " << studentsList[i].scores[3] << " " << studentsList[i].scores[4] << " " << studentsList[i].scores[5] << endl;
cout << "Binary Search = " << counter1 << endl;
cout << "Forget search = " << counter2 << endl;
cout << "RE search = " << counter2 << endl;
cout << "Do you want search for student?(Y/N):";
cin >> response;
}
}
while ((response=='Y')||(response=='y'));
return 0;
}
|