예제 #1
0
파일: main.cpp 프로젝트: mitko100/CPlusPlus
int main()
{	
	auto students = createStudents();

	//sort by first name
	std::sort(students.begin(), students.end(), [](Student&s1, Student& s2)
	{
		return s1.getFirstName() < s2.getFirstName();
	});

	//show only students whose first name is before their last name alphabetically
	std::for_each(students.begin(), students.end(), [](Student& s)
	{
		if (s.getFirstName() < s.getLastName())
		{
			std::cout << s.getFirstName() << "  " << s.getLastName() << std::endl;
		}
	});
	std::cout << std::endl;

	//show only students that have email @abv.bg
	std::for_each(students.begin(), students.end(), [](Student& s)
	{
		if (s.getEmail().find("@abv.bg") != std::string::npos)
		{
			std::cout << s.getFirstName() << "  " << s.getEmail() << std::endl;
		}
	});
	std::cout << std::endl;



	system("pause");
	return 0;
}
int main(int argc, char * argv[])
{
    //checks to make sure that there are 2 arguments - one for input and output
    inputCheck(argv);
    
    //Get the input file name...
    char *inputFileName = *(argv + 1);
    char *outputFileName = *(argv + 2);
    
    //Find out how many students are on the input file...
    int numberOfStudents = getRecordCount(inputFileName);
    
    //Create the number of students depending on the record count...
    Student listOfStudents[numberOfStudents];
    createStudents(listOfStudents, numberOfStudents);
    
    //Read the data of the input file...
    FILE *myFile = openFile(inputFileName);
    
    //Fill out all the student's info...
    fillStudentRecord(myFile, listOfStudents, numberOfStudents);
    
    //sortStudents using the array of student struct
    sortStudents(listOfStudents, numberOfStudents);
    
    //Calculate each student's GPA and recorded in the structure...
    getGPA(listOfStudents, numberOfStudents);
    
    //Calculate each student's Letter Grade and record in the structure...
    getGrade(listOfStudents, numberOfStudents);
    
    //Create ClassGrade structure pointer...
    ClassGrade *classGrade;
    classGrade = (ClassGrade *)malloc((sizeof classGrade) * 20);
    
    //Call functions to calculate the scores...
    getScoreAverage(listOfStudents, classGrade, numberOfStudents);
    getMinScore(listOfStudents, classGrade, numberOfStudents);
    getMaxScore(listOfStudents, classGrade, numberOfStudents);
    
    //Generate and output file with the student grade information
    generateOutputFile(outputFileName, inputFileName, listOfStudents, numberOfStudents);
    
    //Print out student's info...
    printAllStudents(listOfStudents, classGrade, numberOfStudents, inputFileName, outputFileName);
    
    return 0;
}