Documente Academic
Documente Profesional
Documente Cultură
#include <cstring>
#include <cstdlib>
#include <string>
//syntax: student[x].class[y].name
struct Student
{
string name;
int NumOfClasses;
double gpa = 0.0; // Use so can use float integers
Class classes[20]; // Going inside Class structure, b/c classes involve info
from struct Class
};
int main()
{
string sName;
Student students[100];
int iSize = 100;
int iIndex = -1;
int iNumOfStudents = get_info(students, iSize);
double findgpa;
int iFind;
int iX;
iX = get_info(students, iSize);
while(students[iX].name != "")
{
students[iX].gpa = 0.0;
}
iX++;
cin.ignore();
cout << "Enter student name";
return iX;
}
total_units += students.classes[iX].units;
display(students, iSize);
}
display(students,iSize);
}
while(low<=high)
{
mid = (low + high) / 2;
if(students[mid].name.compare(sName)==0)
{
cout << "Student: " << students[mid].ID << " " << students[mid].name <<
endl;
for(z = 0; z < students[mid].num; z++)
{
cout << students[mid].classes[z].name << ", " <<
students[mid].classes[z].units << " units, Grade " <<
students[mid].classes[k].grade;
cout << endl;
}
cout << "GPA: " << students[mid].gpa;
return mid;
}
else if (students[mid].name.compare(sName) > 0)
high = mid -1;
else if (students[mid].name.compare(sName) < 0)
low = mid+1;
}
return -1;
}
}