Mã:
#include <stdio.h>
#include <conio.h>
#include<iostream.h>
#include <graphics.h>
#include <stdlib.h>
#include<dos.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
//--------------------------------------------------------
void ktdh1()
{
int driver = 0, mode;
initgraph(&driver, &mode, "c:\\borlandc\\bgi");
}
/*----------------------------------------------------------------*/
void thoat()
{
setfillstyle(2,10);
bar(0,0,getmaxx(),getmaxy());
setfillstyle(1,BLUE);
bar(20,20,getmaxx()-20,getmaxy()-20 );
setcolor(15);
outtextxy(100,100,"Em xin chan thanh cam on su giup do cua co Lam Thi Ngoc Chau");
outtextxy(100,120,"va cac ban da giup em hoan thanh chuong trinh nay");
outtextxy(150,360,"An phim bat ky de thoat khoi chuong trinh");
getch();
}
/*---------------------------------------------*/
void Gioi_thieu()
{
setfillstyle(2,10);
bar(0,0,getmaxx(),getmaxy());
setfillstyle(1,BLUE);
bar(20,20,getmaxx()-20,getmaxy()-20 );
setcolor(15);
outtextxy(50,35,"Dac ta de tai: Su dung phuong phap do thi de the hien viec bo tri ");
outtextxy(35,60,"lich thi cho hoc sinh THPT .");
outtextxy(35,85,"Yeu cau: Sap xep lich thi trong mot tuan(7 ngay) gom 7 mon thi.");
outtextxy(35,110,"Nhung phai sap xep sao cho cac mon co cung giao vien giang day khong");
outtextxy(35,135,"thi vao 2 ngay lien tiep va moi giao vien khong qua 4 mon thi.");
outtextxy(35,160,"Muc tieu: Su dung cac ngon ngu lap trinh da hoc cac ly thuyet ve Toan ");
outtextxy(35,185,"Roi Rac, Ly Thuyet Do Thi va ket hop voi Ki Thuat Do Hoa de giai bai toan");
outtextxy(35,215,"Ve Lap Trinh: Dua vao Thuat toan chu trinh Hamilton da thiet lap");
outtextxy(35,240,"cho ra mot so do sap xep lich thi voi nhieu mau sac va than hien voi ");
outtextxy(35,255,"nguoi su dung. ");
outtextxy(150,385,"AN PHIM BAT KY DE TRO VE MENU");
getch();
cleardevice();
}
/*----------------khoi tao do hoa-----------------*/
void ktdh()
{
int Gd,Gm;
Gd=0;
initgraph(&Gd,&Gm,"c:\\borlandc\\bgi");
if (graphresult()!=0)
exit(1);
}
/*--------Thu tuc in ra mot xau kieu chu 3D--------------*/
void chu3d(int c,int h,int b,int mb,int mc, char st[50])
{
int i;
for(i=1;i<=b;i++)
{
setcolor(mb);
outtextxy(c+i,h+i,st);
}
setcolor(mc);
outtextxy(c,h,st);
}
/*-------------------------------------*/
void hoten(int tx,int ty)
{
char ht1[50],ht2[50];
settextstyle(4,0,3);
chu3d(tx+5,ty-10,2,4,10," Ths: Lam Thi Ngoc Chau");
settextstyle(3,0,3);
chu3d(tx+5,ty+20,2,4,8," Tran Van To Em");
settextstyle(0,0,1);
outtextxy(370,405,"MSSV: 0751010019");
settextstyle(3,0,3);
chu3d(tx+5,ty+60,2,4,8," Phan Van Toan ");
settextstyle(0,0,1);
outtextxy(370,445,"MSSV: 0751010119");
settextstyle(2,0,7);
chu3d(tx-30,ty-10,2,2,12, " GV huong dan: ");
chu3d(tx-30,ty+20,1,2,12," SV thuc hien: ");
settextstyle(1,0,1);
chu3d(tx+0,ty+100,2,4,9," An phim so tuong ung hoac phim mui ten de chon ");
}
/*--------Thu tuc nho hien thi thong bao--------------*/
void huong_dan()
{
setcolor(2);
settextstyle(0,0,1);
outtextxy(210,10,"KHOA KY THUAT - CONG NGHE");
outtextxy(220,30,"TRUONG DAI HOC TAY DO");
settextstyle(0,0,1);
outtextxy(255,50,"===******===");
settextstyle(7,0,1);
chu3d(420,130,2,4,10,"NIEN LUAN I");
settextstyle(8,0,4);
chu3d(130,80,4,5,15,"SAP XEP LICH THI");
}
/*------------Thu tuc tao cua so cho menu---------------*/
void cua_so(int c1,int h1,int c2,int h2, int n,int mt,int md,int mn)
{
int i;
for(i=1;i<=n;i++)
{
setcolor(mt);
line(c1+i,h1+i,c2-i,h1+i);
line(c1+i,h1+i,c1+i,h2-i);
setcolor(md);
line(c1+i,h2-i,c2-i,h2-i);
line(c2-i,h2-i,c2-i,h1+i);
}
setfillstyle(6,mn);
bar(c1+n,h1+n,c2-n,h2-n);
}
/*-------------chuong trinh sap xep---------------*/
// Ham phu 1.
void printc(int x,int y,char *s,int color)
{
gotoxy(x,y);
textcolor(color);
cprintf(s);
}
// Ham phu 2.
void printcc(int x,int y,char *s,int color,int bk)
{
gotoxy(x,y);
textbackground(bk);
textcolor(color);
cprintf(s);
}
//--------------------------------------------
// Xay dung hop thoai.
void khungdoi(int x1,int y1,int x2,int y2,char *st,int linecolor,int bkcolor)
{
int i,j;
textbackground(bkcolor);
for(i=x1+2;i<x2+3;i++)
for(j=y1+1;j<y2+2;j++)
printc(i,j,"Û",0);
printc(x2,y2,"¼",linecolor);
printc(x1,y2,"È",linecolor);
printc(x2,y1,"",linecolor);
printc(x1,y1,"É",linecolor);
gotoxy(x2-1,y1+8);
printf("---->");
gotoxy(x2+21,y1+8);
printf("---->");
gotoxy(x2-1,y1+18);
printf("<----");
gotoxy(x2+21,y1+18);
printf("<----");
gotoxy(38,y2+7);
printf("------------------------");
gotoxy(61,y2+6);
printf("%c",108);
gotoxy(38,y2+7);
printf(".");
gotoxy(38,y2+8);
printf("%c",25);
gotoxy(38,y2+12);
printf("-----------------------");
gotoxy(38,y2+11);
printf("%c",108);
gotoxy(61,y2+12);
printf(".");
gotoxy(61,y2+13);
printf("%c",25);
gotoxy(16,y2+6);
printf("%c",24);
gotoxy(16,y2+7);
printf("%c",108);
gotoxy(16,y2+8);
printf("%c",108);
gotoxy(16,y2+9);
printf("%c",108);
gotoxy(16,y2+10);
printf("%c",108);
gotoxy(16,y2+11);
printf("%c",108);
gotoxy(16,y2+12);
printf("%c",108);
gotoxy(16,y2+13);
printf("%c",108);
gotoxy(14,10);
printf("Thu 2");
gotoxy(37,10);
printf("Thu 3");
gotoxy(58,10);
printf("Thu 4");
gotoxy(46,17);
printf("Thu 5");
gotoxy(58,23);
printf("Thu 6");
gotoxy(37,23);
printf("Thu 7");
gotoxy(14,23);
printf("Chu Nhat");
for(i=x1+1;i<x2;i++)
{
printc(i,y1,"Í",linecolor);
printc(i,y2,"Í",linecolor);
for(j=y1+1;j<y2;j++)
printc(i,j,"Û",bkcolor);
}
for(i=y1+1;i<y2;i++)
{
printc(x1,i,"º",linecolor);
printc(x2,i,"º",linecolor);
}
int k;
k=strlen(st);
printcc((x1+x2-k)/2,y1,st,linecolor,bkcolor);
textcolor(linecolor);
gotoxy(x2-5,y1);
cprintf("[ ]");
textcolor(10);
gotoxy(x2-4,y1);
cprintf("%c",254);
}
//-----------------------------------------------------------------
struct lichthi
{ char hoten[50];
char mon[20];
int mau;
};
//----------------------------------------------------------------
void sapxep(lichthi lt[])
{ lichthi tam;
for(int i=0;i<7;i++)
for(int j=i+1;j<7;j++)
{ if (strcmp(lt[i].hoten,lt[j].hoten)==0)
{ tam=lt[i+1];
lt[i+1]=lt[j];
lt[j]=tam;
i++;
}
}
}
//-----------------------------------------------------------------
void lich(struct lichthi lt[],struct lichthi b[])
{ int max,min,lon,nho,t,c=7;
for(int i=0;i<7;i+=2)
{ max=-1;min=4;lon=-1;nho=-1;
//-----------tim so mon nhieu nhat-----------
for(int j=0;j<c;j++)
{ t=0;
for(int d=0;d<c;d++)
if(strcmp(lt[j].hoten,lt[d].hoten)==0)
t++;
if(max<t&&(i==0||strcmp(lt[j].hoten,b[i-1].hoten)!=0))
{ max=t;
lon=j;
}
}
//-----------chen phan tu lon nhat vao mang b----------
b[i]=lt[lon];
for(j=lon;j<c;j++)
lt[j]=lt[j+1];
c--;
//-----------tim giao vien day it mon nhat----------
for(j=c-1;j>=0;j--)
{ t=0;
for(int d=c-1;d>=0;d--)
if(strcmp(lt[j].hoten,lt[d].hoten)==0)
t++;
if((min>t)&&strcmp(lt[j].hoten,b[i].hoten)!=0)
{ min=t;
nho=j;
}
}
//-----------chen phan tu nho nhat vao mang b------------
b[i+1]=lt[nho];
for(j=nho;j<c;j++)
lt[j]=lt[j+1];
c--;
}
}
//========================
void xuat(struct lichthi b[]){
textbackground(b[0].mau);
window(10,11,22,12);
clrscr(); //o thu 1
textbackground(b[1].mau);
window(32,11,44,12);
clrscr(); // o thu 2
textbackground(b[2].mau);
window(54,11,66,12);
clrscr(); // o thu 3
textbackground(b[3].mau);
window(32,16,44,17);
clrscr(); //o thu 4
textbackground(b[4].mau);
window(10,21,22,22);
clrscr(); // o thu 5
textbackground(b[5].mau);
window(32,21,44,22);
clrscr(); // o thu 6
textbackground(b[6].mau);
window(54,21,66,22);
clrscr();
window(1,1,80,25); // o thu 7
printcc(14,12,b[0].mon,0,b[0].mau);
printcc(37,12,b[1].mon,0,b[1].mau);
printcc(59,12,b[2].mon,0,b[2].mau);
printcc(37,17,b[3].mon,0,b[3].mau);
printcc(15,22,b[4].mon,0,b[4].mau);
printcc(37,22,b[5].mon,0,b[5].mau);
printcc(58,22,b[6].mon,0,b[6].mau);
}
// Tan man nen.
void Nen()
{
textmode(C80);
textbackground(0);
textcolor(14);
clrscr();
gotoxy(20,2);
printf("So Do Bo Tri Lich Thi Cua Hoc Sinh THPT.");
gotoxy(1,2);
window(1,3,80,25);
textbackground(15);
textcolor(8);
clrscr();
for(int i=0;i<23.35*24-1;i++)
printf(".");
window(1,1,80,25);
khungdoi(2,4,26,7," Chu Thich ",14,1);
}
//-----------------------------------------------------------
// Hien thong tin so do.
void ThongTin()
{
lichthi b[50];
printcc(4,5,"Nhung Mon Cung Giao",15,1);
printcc(4,6,"Vien Thi Cung Mau",15,1);
}
//--------------------------------------------------------
void demo()
{ ktdh1();
lichthi lt[50];
lichthi b[50];
char hoten[30];
char mon[30];
int i;
textcolor(1);
setbkcolor(1);
clrscr();
printf("+------------------------------------------------------------------------------+");
printf(": Nhap Du Lieu gom: Giao Vien,Mon Thi, Mau :");
printf("+------------------------------------------------------------------------------+");
printf("
");
for(i=0;i<7;i++){
printf("
Nhap Giao Vien Thu %d : ",i);
gets(lt[i].hoten);
printf(" Nhap Mon Thi Thu %d : ",i);
gets(lt[i].mon);
printf(" Nhap Mau Cua Giao Vien Thu %d : ",i);
scanf("%d",<[i].mau);
fflush(stdin);
}
Nen();
ThongTin();
sapxep(lt);
lich(lt,b);
xuat(b);
getch();
}
void sapxep2()
{
ktdh1();
demo();
closegraph();
}
/*------------Thu tuc hien menu-------------------*/
void menu_con(int tt)
{
switch (tt)
{
case 1:
{
setfillstyle(0,0);
bar(230,180,600,332);
setcolor(15);
outtextxy(235,200,"- Gioi thieu tong quan bai toan");
break;
}
case 2:
{
setfillstyle(0,0);
bar(230,180,500,332);
setcolor(15);
outtextxy(235,240,"- Thuc hien ct sx lich thi");
break;
}
case 3:
{
setfillstyle(0,0);
bar(230,180,500,332);
setcolor(15);
outtextxy(235,220,"- Thoat chuong trinh");
break;
}
}
}
void ve_menu(int chon)
{
int i;
char *mang_mn[5];
mang_mn[1]=" 1. Gioi Thieu";
mang_mn[2]=" 2. Chay Demo";
mang_mn[3]=" 3. Thoat";
setcolor(6); settextstyle(0,0,1);
for(i=1;i<=3;i++)
{
if (i==chon)
{
cua_so(70,150+i*30,220,180+i*30,4,8,15,13);
menu_con(i);
}
else
cua_so(70,150+i*30,220,180+i*30,4,15,2,4);
outtextxy(73,160+i*30,mang_mn[i]);
}
}
/*----------Thu tuc tao menu trong do hoa--------------*/
void menu()
{
char key;
int stt;
stt=1;
hoten(100,350);
ve_menu(stt);
while (1==1)
{
key=getch();
switch (key)
{
/*=======kiem tra phim moi duoc an========*/
case 75:
{
/*======phim mui ten trai====*/
stt--;
if (stt<1)
stt=3;
break;
}
case 77:
{
/*======phim mui ten phai====*/
stt++;
if (stt>3)
stt=1;
break;
}
case 72:
{
/*======phim mui ten len====*/
stt--;
if (stt<1)
stt=3;
break;
}
case 80:
{
/*======phim mui ten xuong====*/
stt++;
if (stt>3)
stt=1;
break;
}
case 13:
{
switch (stt)
/*======phim Enter duoc chon====*/
{
case 1:
{
cleardevice();ktdh1();
Gioi_thieu();
break;
}
case 2:
{
//Ung voi menu 3
cleardevice();
sapxep2();
break;
}
case 3:
{
cleardevice();
thoat();
exit(1);
}
}
/*dong switch*/
break;
}
case 27:
{
exit(1);
break;
} /*An Esc de thoat ngay*/
case 49:
{
cleardevice(); ktdh1();
Gioi_thieu();
break;
}
case 50:
{
cleardevice();
sapxep2();
//Chay demo
break;
}
case 51:
{
cleardevice();
thoat();
return;
}
}
hoten(100,350);
huong_dan();
ve_menu(stt);
}
}
/*=============Ket thuc menu do hoa==============*/
/*---------------------------------------------------*/
void main()
{
ktdh1();
huong_dan();
menu();
getch();
closegraph();
}
mọi người giúp em với
khi đề cập đến đội hình MU, không thể ko nói tới một trong các câu lạc bộ bóng đá huyền thoại và với tầm ảnh hưởng nhất trong lịch sử của môn thể thao vua. Với hơn 1 thế kỷ còn đó và phát triển,...
Đội hình MU - Manchester United:...