Danh mục

Bài tập lớn NLHĐH

Số trang: 13      Loại file: doc      Dung lượng: 32.50 KB      Lượt xem: 11      Lượt tải: 0    
tailieu_vip

Phí tải xuống: 2,000 VND Tải xuống file đầy đủ (13 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Đây là tài liệu môn HĐH nâng cao mà mình tìm được, hy vọng với những giải thuật sẽ giúp ích cho các bạn. Tài liệu không tránh khỏi sai sót, mời các bạn cùng tham khảo.
Nội dung trích xuất từ tài liệu:
Bài tập lớn NLHĐHBài tập lớn NLHĐH#include#include#include#include#include#include#include#includeint *tentt,*ten; //tentt: ten cac tt nhap vao, ten: danh sach ten tt xuat raunsigned int *txh,*tth,*moctg,*daxh; //txh,tth:thoi gian xh va th cau tien trinh.daxh:danh dau tien trinh da xh trong hang doiint n,m; //n:so tien trinh,m:so o duoc ve//HAM NHAP DU LIEUvoid nhapdl(){coutn;tentt=(int*)malloc(n*sizeof (int));txh=(unsigned int*)malloc(n*sizeof (int));tth=(unsigned int*)malloc(n*sizeof (int));daxh=(unsigned int*)malloc(n*sizeof (int));gotoxy(35,4);coutt=txh[(l+r)/2];int i=l,j=r;while(id2++;}d1++;}}//HAM THUC HIEN CUA THUAT TOAN SJFvoid thSJF(int *hangdoi, int &xh,int &so,unsigned int *tthhd,unsigned int *tconlai,int&m){if(so>0 || xh{moctg[m]=txh[i];tconlai[so-1]-=moctg[m]-moctg[m-1];i=n+1; //Neu co tien trinh ngat -> dung tien trinh dang thuc hien}if(i==n) so--; //Neu khong co tien trinh ngat -> thuc hien xong tt dang th -> loai bokhoi hang doi}}if(so>0 || xhso++; xh++; daxh[i]=1;hangdoi[so-1]=tentt[i];tthhd[so-1]=tth[i];tconlai[so-1]=tth[i];}//Sap xep lai hang doiint tg;if(so>1){for(int i=0;i0){ten[m]=hangdoi[so-1];moctg[m+1]=moctg[m]+tconlai[so-1];m++; int tam;for(int i=0;i//HAM THUC HIEN THUAT TOAN SRTvoid SRT(int &m){settextstyle(1,0,1);settextjustify(1,1);outtextxy(320,80,Thuat toan SRT);unsigned int *tthhd,*tconlai;int *hangdoi,so=0,xh=0;ten=(int*)calloc(m+1,sizeof(int));moctg=(unsigned int*)calloc(m+2,sizeof(int));hangdoi=(int*)calloc(n,sizeof(int));tthhd=(unsigned int*)calloc(n,sizeof(int));tconlai=(unsigned int*)calloc(n,sizeof(int));m=0;moctg[0]=0;for(int i=0;i0 || xhif(so>0) // Neu so phan tu hang doi >0, dua phan tu dau hang doi vao thuc hien{if(tthtr[so-1] dua no ve cuoi hang doi{moctg[m+1]=moctg[m]+q;ten[m]=hangdoi[so-1];for(int i=so-1;i>0;i--){hangdoi[i]=hangdoi[i-1];tthtr[i]=tthtr[i-1];daxh[i]=daxh[i-1];}hangdoi[0]=ten[m];int vt;for(i=0;i}if(so>0 || xhsettextjustify(1,2);settextstyle(0,0,1);int ax,ay,bx,by,rong=40; //Toa do cac o vuong can veint d=0,i=0,j=0; //d:So o can ve; i:Ve o theo hang; j:Xuong dong moi khi het hangchar *s;while(d620) //Neu so o vuong khong the chua het tren mot hang->xuong hang{ i=0;j++;}ax=210+i*rong; ay=120+5+j*40; bx=210+rong+i*rong; by=120+5+20+j*40; //Tinhtoa do cac o vuongsetcolor(WHITE);rectangle(ax,ay,bx,by); //Ve o vuongitoa(ten[d],s,10);setcolor(YELLOW);settextjustify(1,1);outtextxy((ax+bx+textwidth(P))/2,(ay+by)/2,s); //Xuat cac ten tien trinhsettextjustify(2,1);outtextxy((ax+bx+textwidth(P))/2-textwidth(s)/2,(ay+by)/2,P);settextjustify(1,2); setcolor(LIGHTGRAY);itoa(moctg[d],s,10);outtextxy(ax,by+3,s); //Xuat cac moc thoi gianif(i==360/rong){itoa(moctg[d+1],s,10);outtextxy(bx,by+3,s);}if(ten[d]==-99) //Tao o trong{setfillstyle(0,0); bar(ax+3,ay+3,bx-3,by-3);}d++; i++; //Dem tong so o da ve}itoa(moctg[d],s,10);outtextxy(bx,by+3,s);}//Ham kt de tinh thoi gian cho doi cho cac tien trinhint ktcomat(int a,int ds[],int &d){int i=0;while(i{int *ds,*tkt,*tcd; //ds:cac tien trinh da duoc tinh, tkt:mang luu tg ket thuc cua cac tientrinh//tcd:mang luu thoi gian cho cua cac tien trinhfloat ttb; //ttb:thoi gian cho doi trung binhds=(int*)calloc(1,sizeof(int));tkt=(int*)calloc(n,sizeof(int));tcd=(int*)calloc(n,sizeof(int));int i=m-1,d=0; ds[0]=-99;while(d=0) //Duyet nguoc tu cuoi mang ten,moctg.Neu tt nao chua comat trong ds cac tien trinh da duoc tinh tg kt -> lay moctg[i+1] la tg ket thuc{if(!ktcomat(ten[i],ds,d)){tkt[d]=moctg[i+1];d++;ds=(int*)realloc(ds,(d+1)*sizeof(int));ds[d]=ten[i];}i--;}//Sap lai mang thoi gian ket thuc theo dung tenttfor(i=0;i}void gt(){setcolor(WHITE);settextstyle(1,0,2);settextjustify(0,2);outtextxy(80,80,DANH SACH THANH VIEN NHOM 1);settextstyle(1,0,1);outtextxy(80,100,1.Nguyen Tuan Anh);outtextxy(80,115,2.Pham Tuan Luong);outtextxy(80,130,3.Do thi Hong Van);outtextxy(80,145,4.Nguyen Van Bat);outtextxy(80,160,5.Nguyen Trung Hieu);outtextxy(80,175,6.Doan xuan Nghia);getch();}void xuatdebai(int &n,int *tentt,unsigned int *txh,unsigned int *tth){char as[30];setcolor(YELLOW);settextstyle(0,0,1);settextjustify(0,2);outtextxy(10,40,TenTT);outtextxy(60,40,TXH);outtextxy(90,40,TTH);rectangle(5,35,120,55+15*n);rectangle(5,15,120,35);settextjustify(1,2);outtextxy(60,25,DE BAI);settextjustify(0,2);for(int i=0;i{clrscr();restorecrtmode(); //tro ve man hinh soan thaonhapdl(); //Nhap du lieus:restorecrtmode();//Dua ra menu cho nguoi dung chon lua thuat toangotoxy(5,4);coutelseif(k==4) RR(m);elseif(k==6) { gt(); goto s;}else goto s;if(k!=6){vesodogrant(ten,m,moctg); //Ve so do Grantxuatdebai(n,tentt,txh,tth); //Xuat de baifloat ttb=floor(TGCDTB()*100+0.5)/100; //Tinh thoi gian cho doi trung binh cuathuat toansetcolor(RED); settextstyle(1,0,1);char as[30];settextjustify(1,2); ...

Tài liệu được xem nhiều:

Gợi ý tài liệu liên quan: