Example #1
0
void main() {
	strcpy( c1.set_name, "CO101's Student" );
	strcpy( c2.set_name, "CO102's Student" );
	strcpy( non.set_name, "Not taking Course" );
	int gdriver = DETECT, gmode, errorcode;
	initgraph(&gdriver, &gmode, "..\\bgi");
	errorcode = graphresult();
	if (errorcode != grOk)  /* an error occurred */
	{
		printf("Graphics error: %s\n", grapherrormsg(errorcode));
		printf("Press any key to halt:");
		getch();
		exit(1);             /* return with error code */
	}
	left = getmaxx() / 4 - 50;
	top = getmaxy() / 4 - 50;
	right = getmaxx() / 4 + 300;
	bottom = getmaxy() / 4 + 100;
	int selopt = 1;
	mainmenu();
	d_op(1, 0);
	char cursor;
	do {
		cursor = getch();
		switch( cursor )
		{
		case 80://B
			if( selopt < szopt ) {
				selopt++;
				d_op(selopt, 1);
			}
			break;
		case 72://up
			if( selopt > 1 ) {
				selopt--;
				d_op(selopt, -1);
			}
			break;
		case 13:
			cleardevice();
			gotoxy( 1, 1 );
			switch(selopt)
			{
			case 1: //add new student
				char add_stu;
				do {
					bs.insert();
					cout << "\nAdd more (y/n): ";
					add_stu = getch();
				} while( add_stu != 'n' );
				break;
			case 2:
				cout << endl;
				c1.disp_stu();
				c2.disp_stu();
				pak(); gc();
				break;
			case 3:
				cout << endl;
				non.disp_stu();
				pak(); gc();
				break;
			case 4:
				c1.sort();
				c2.sort();
				non.sort();
				cout << "\n\nSimple Sorted values"
					<< "\n--------------------\n";
				c1.disp_stu();
				c2.disp_stu();
				non.disp_stu();
				pak(); gc();
				break;
			case 5:
				c1.q_sort( 1, c1.max );
				c2.q_sort( 1, c2.max );
				non.q_sort( 1, non.max );
				cout << "\n\nQuick Sorted values"
					<< "\n-------------------\n";
				c1.disp_stu();
				c2.disp_stu();
				non.disp_stu();
				pak(); gc();
				break;
			case 6:
				bs.p(); pak(); gc();
				break;
			case 7:
				cout << endl;
				c1.disp_stu();
				c2.disp_stu();
				non.disp_stu();
				cout << "\n\nStudents course lists taking;";
				c1.diff_stu( &c2 );
				c1.union_stu( &c2 );
				c1.intersection_stu( &c2 );
				pak(); gc();
				break;
			case 8: exit(0); break;
			default:
				cout << "\n\nWrong option ";
				pak(); gc();
				break;
			}
			cleardevice();
			mainmenu();
			d_op(selopt, 0);
			break;
		default:
			break;
		}
	} while( cursor != 27 );
	closegraph();
}// end main