编辑代码

#include <iostream>
using namespace std;
struct Course
{
	char ClassName[100];
	int begin1;
	int begin2;
	int eng1;
	int eng2;
};
void Class(Course cla[], int count)
{
	cout << "《课程名称》\t" << "开始时间" << "\t结束时间" << endl;
	for (int i = 0; i < count; i++)
	{
		cout << cla[i].ClassName << "\t" << cla[i].begin1 << ":" << cla[i].begin2 << "\t\t" << cla[i].eng1 << ':' << cla[i].eng2 << endl;
	}
	cout << endl;
}
void sel(Course S[])
{
	cout << "需要排序的课程:" << endl;
	Class(S, 5);
	Course Section;
	for (int i = 0; i < 5; i++)
	{
		for (int j = i + 1; j < 5; j++)
		{
			if (S[i].eng1 > S[j].eng1)
			{
				Section = S[j];
				S[j] = S[i];
				S[i] = Section;
			}
			if (S[i].eng1 == S[j].eng1)
			{
				if (S[i].eng2 > S[j].eng2)
				{
					Section = S[j];
					S[j] = S[i];
					S[i] = Section;
				}
			}
		}
	}
	Section = S[0];
	int j = 1;
	for (int i = 1; i < 5; i++)
	{
		if (S[i].begin1 > Section.eng1)
		{
			S[j] = S[i];
			Section = S[i];
			j++;
		}
		if (S[i].begin1 == Section.eng1)
		{
			if (S[i].begin2 > Section.eng2)

			{
				S[j] = S[i];
				Section = S[i];
				j++;
			}
		}
	}
	cout << "排到A课室的课程为:" << endl;
	Class(S, j);

}


int main() {

	Course Class[5] = { 
		{"高等数学",8,00,9,30},
		{"电子商务  ",8,30,10,00},
		{"数据结构  ",9,30,12,00},
		{"计算机基础",10,00,11,00},
		{"C语言     ",11,30,12,30} };
	sel(Class);
}