Vous êtes sur la page 1sur 34

#include<stdio.

h>
#include<conio.h>
#include<io.h>
#include<string.h>
#include<dos.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>

typedef struct processus


{
int num;
int DA;
int TE;
int TES;
processus *suivant;
}processus;
processus *dernier, *p, *tete=NULL;
processus *k;
int nbr_p=0,deb;
int M[100][70];
void heure();
void trie_inf();
int Menu1(void);
void trie_te();
void algo(void);
void Cadre(int,int,int,int);
void Cadre1(int,int,int,int);
void menu(void);
void triangle();
void Entete();
void constuire(void);
void file_attente(void);
int file_attente_inf(void);
int random (void);
void affichage();
void generer(void);
void supprimer();
void trie_da();
void afficher_trie();
void emsi();
void affichage_srt();
void trie_da_te();
int elu(int i);
void srt();
int TES(int i);
void afficher_liste(int nbr,int l,int ok);
void afficher_quitter();
void afficher_matrix();
int Menu0(void);
void afficher_generer();
void tnt_file(int nbr,int l,int ok);
void afficher_file();
void afficher_creer_file();
void tourniquet();

void main()
{
emsi();
}
void Entete()
{
char tmpbuf[128],datebuf[128];
_strtime( tmpbuf );
_strdate( datebuf );
printf("\xc9");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd
\xcd\xcd\xcd\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd
\xcd\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd
\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd");
printf("\xbb");
printf("\n\xba %s \xba ",tmpbuf);
cprintf("Projet realis\x82 par : Agouti hicham et Elbourkadi mouhssin
");
printf("\xba\n");
textcolor(7);
printf("\xc8");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd
\xcd\xcd\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd
\xcd\xcd\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd
\xcd\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd");
printf("\xbc");
printf("\n\n");
textcolor(7);textbackground(0);
}
void heure()
{
char tmpbuff[128];
char chaine[]="Projet realis\x82 par : Agouti hicham et Elbourkadi mouhssin";
int h=0;
window(17,2,75,2);
clrscr();
window(1,1,80,50);
do{ _strtime( tmpbuff );
_setcursortype(_NOCURSOR);
gotoxy(1,1);printf("\n\xba %s \xba ",tmpbuff);
gotoxy(17+h,2);
cprintf("%c",chaine[h]);delay(100);
if(chaine[h]=='\0')
{
gotoxy(17,2);printf("
");
h=-1;
}
h++;

}while(!kbhit());
}
int Menu0(void)
{
int i=0,c=20,l=20,n,j;
char choix;

do{
window(20,15,57,29);textbackground(1);clrscr();
switch(i)
{
case 0:
window(24,18,52,22);textbackground(12);clrscr();cprintf("\n \xDB Sectio
n file d'attente");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB Section
algorithmes");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB QUITTER
");
window(1,1,80,50);textbackground(0);
for(j=21;j<27;j++)
{
gotoxy(18,j);printf(" ");
}
gotoxy(18,19);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
for(j=20;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
Cadre1(10,35,70,47);
gotoxy(18,35);printf("\xC1");
afficher_liste(3,40,1);
break;
case 1:window(24,18,52,22);textbackground(1);clrscr();cprintf("\n \xDB Section
file d'attente");
window(24,21,52,23);textbackground(12);clrscr();cprintf("\n \xDB Sectio
n algorithmes");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB QUITTER
");
window(1,1,80,50);
for(j=18;j<27;j++)
{
gotoxy(18,j);printf(" ");
}
for(j=23;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
gotoxy(18,22);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
afficher_matrix();
break;
case 2:window(24,18,52,22);textbackground(1);clrscr();cprintf("\n \xDB Section
file d'attente");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB Section
algorithmes");
window(24,24,52,26);textbackground(12);clrscr();cprintf("\n \xDB QUITTE
R");
window(1,1,80,50);
for(j=18;j<26;j++)
{
gotoxy(18,j);printf(" ");
}
gotoxy(18,25);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
afficher_quitter();
break;
}
fflush(stdin);choix=getch();
switch(choix)
{
case 80:
if(i==2) i=0;
else i++;
break;
case 72:
if(i==0) i=2;
else i--;
break;
}
}while(choix!=13);
window(1,1,50,80);textbackground(0);clrscr();textcolor(7);
return i;
}
void afficher_matrix()
{
int m[20][30],i,j,k=0;
randomize();
while(!kbhit())
{
window(46,37,65,46);textbackground(0);clrscr();
for(i=0;i<=9;i++)
for(j=0;j<20;j++)
m[i][j]=random(9);
for(i=0;i<=9;i++)
for(j=0;j<20;j++)
{gotoxy(j+1,i+1);textcolor(random(14));cprintf("%d",m[i][j]);}
if(k==0||k==1||k==2||k==3)
{window(20,37,45,46);textbackground(0);textcolor(7);clrscr();
gotoxy(1,1);printf(" \\ \xB3 /");
gotoxy(1,2);printf("\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,3);printf(" \xDB\xDB\xDB\xDB\xF8\xDB");
gotoxy(1,4);printf(" \xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,5);printf(" \xDB\xDB\xDB\xDB\xDB");
gotoxy(1,6);printf(" \xDB\xDB\xDB \xFE\xFE");
gotoxy(1,7);printf(" \xDB\xDB\xDB\xDB\xDB\xDB");
k++;
}
else
if(k==4)
{window(20,37,45,46);textbackground(0);textcolor(7);clrscr();
gotoxy(1,1);printf(" \\ \xB3 /");
gotoxy(1,2);printf("\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,3);printf(" \xDB\xDB\xDB\xDB\xF8\xF8\xF8");
gotoxy(1,4);printf(" \xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,5);printf(" \xDB\xDB\xDB\xDB\xDB");
gotoxy(1,6);printf(" \xDB\xDB\xDB \xFE\xFE");
gotoxy(1,7);printf(" \xDB\xDB\xDB\xDB\xDB\xDB");
k++;
}
else
if(k==5||k==6)
{window(20,37,45,46);textbackground(0);textcolor(7);clrscr();
gotoxy(1,1);printf(" \\ \xB3 /");
gotoxy(1,2);printf("\xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,3);printf(" \xDB\xDB\xDB\xDB\xF8\xF8\xF8\xF8");printf("O");
gotoxy(1,4);printf(" \xDB\xDB\xDB\xDB\xDB\xDB");
gotoxy(1,5);printf(" \xDB\xDB\xDB\xDB\xDB");
gotoxy(1,6);printf(" \xDB\xDB\xDB");
gotoxy(1,7);printf(" \xDB\xDB\xDB \xFE\xFE");
gotoxy(1,8);printf(" \xDB\xDB\xDB\xDB\xDB\xDB");
k++;
}
if(k==7)k=0;
if(!kbhit())delay(200);
}
window(11,36,69,46);textbackground(0);clrscr();window(1,1,80,50);textcolor(7);
}
void afficher_quitter()
{
int cpt=3,i;
gotoxy(19,45);printf("\xC0\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\x
C4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4");
window(46,36,60,38);textbackground(0);clrscr();
gotoxy(1,1);printf("\\ /");
gotoxy(1,2);printf(" \\ /");
gotoxy(1,3);printf(" \\ /");

while(!kbhit())
{

if(cpt==3)
{
window(46,39,58,45);textbackground(7);clrscr();
window(58,39,60,45);textbackground(3);clrscr();
gotoxy(3,1);textcolor(RED+BLINK);cprintf("\xF9");
gotoxy(2,2);cprintf("1");
textcolor(7);
textcolor(0);gotoxy(1,3);cprintf("\xB0\xB0\xB0");
gotoxy(1,3);cprintf("\xB1\xB1\xB1");
gotoxy(1,4);cprintf("\xB1\xB1\xB1");
gotoxy(2,7);textcolor(RED);cprintf("\xDF");textcolor(7);
for(i=0;i<8;i++)
{
if(!kbhit())
{
window(1,1,80,50);
gotoxy(18,43);printf(" ");gotoxy(20,43);printf(" ");
gotoxy(18,41);printf("\xB3");gotoxy(20,41);printf("\xB3");
gotoxy(18,42);printf("\\");gotoxy(20,42);printf("/");
gotoxy(19,42);printf("\xC2");
gotoxy(19,43);printf("\xB3");
gotoxy(19,44);printf("\xB3");
Cadre1(17,39,21,40);
window(18,40,18,40);textbackground(RED);clrscr();window(20,40,20,40);clrscr();
window(48,40,55,44);textbackground(0);clrscr();
clrscr();textcolor(15);
gotoxy(1,1);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
gotoxy(1,2);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
gotoxy(1,3);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
gotoxy(1,4);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
gotoxy(1,5);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
delay(50);
clrscr();delay(50);
}
}
cpt++;
}
else
{
window(46,39,58,45);textbackground(7);clrscr();
window(58,39,60,45);textbackground(3);clrscr();
textcolor(7);
textcolor(0);gotoxy(1,3);cprintf("\xB0\xB0\xB0");
gotoxy(1,3);cprintf("\xB1\xB1\xB1");
gotoxy(1,4);cprintf("\xB1\xB1\xB1");
gotoxy(2,7);cprintf("\xDF");textcolor(7);
for(i=0;i<12;i++)
{
if(!kbhit())
{

window(1,1,80,50);
gotoxy(18,41);printf(" ");gotoxy(20,41);printf(" ");
gotoxy(18,42);printf("\xB3");gotoxy(20,42);printf("\xB3");
gotoxy(18,43);printf("\\");gotoxy(20,43);printf("/");
gotoxy(19,42);printf(" ");
gotoxy(19,43);printf(" ");
gotoxy(19,43);printf("\xC2");

Cadre1(17,39,21,40);
window(18,40,18,40);textbackground(7);clrscr();window(20,40,20,40);clrscr();
window(48,40,55,44);textbackground(0);clrscr();
clrscr();
delay(50);
}
}

cpt=3;
}

}
window(11,36,69,46);textbackground(0);textcolor(7);clrscr();

}
void afficher_liste(int nbr,int l,int ok)
{
int n,j,c;
do
{
window(12,l,65,45);textbackground(0);clrscr();
for(n=1,c=1;n<=nbr;n++,c++)
{
for(j=0;j<8;j++)
if(!kbhit())
delay(50);
window(c*18,l,(c*18)+8,l+4);textbackground(6);clrscr();
gotoxy(4,3);textcolor(0);cprintf("P%d",n);textcolor(7);
if(c==1&&n==1)
{textcolor(RED+128);gotoxy(1,2);cprintf("\xDE");
gotoxy(1,3);cprintf("\xDE");
gotoxy(1,4);cprintf("\xDE");
window(12,l+1,17,l+1);textbackground(0);textcolor(RED);putch(254);cpri
ntf("TETE");
}

if((n!=nbr_p&&n%3!=0)||(ok==0&&n!=nbr_p)){
if(!kbhit())delay(50);
window((c*18)+9,l+1,(c*18)+20,l+5);
textcolor(2);textbackground(0);
gotoxy(1,1);cprintf("\xB8");
gotoxy(1,3);cprintf("\xBE");
gotoxy(1,2);if(!kbhit())delay(50);cprintf("\xC6");if(!kbhit())delay(50)
;cprintf("\xAF");if(!kbhit())delay(50);cprintf("\xAF");
if(!kbhit())delay(50);cprintf("\xAF");if(!kbhit())delay(50);
cprintf("\xAF");if(!kbhit())delay(50);cprintf("\xAF");if(!kbhit
())delay(50);cprintf("\xAF");
if(!kbhit())delay(50);cprintf("\xAF");if(!kbhit())delay(50);cpr
intf("\xB4");
gotoxy(9,1);cprintf("\xD5");
gotoxy(9,3);cprintf("\xD4");
}
if(n%3==0&&ok==0&&n!=nbr_p)
{window((c*18)+11,l+1,(c*18)+20,l+7);textbackground(0);clrscr(
);
gotoxy(1,2);printf("\xBF");
gotoxy(1,3);printf("\xB3");
gotoxy(1,4);printf("\xB3");
gotoxy(1,5);printf("\xB3");
gotoxy(1,6);printf("\xB3");
gotoxy(1,6);printf("\xD9");
window(18,l+6,50,l+6);
for(j=1;j<48;j++)
printf("\xC4");
if(ok==0){
window(16,l+6,17,l+12);textbackground(0);clrscr();
gotoxy(1,5);cprintf("\xB3\xD5");
gotoxy(1,6);cprintf("\xC0\xB4");
gotoxy(2,7);cprintf("\xD4");
gotoxy(1,1);cprintf("\xDA\xC4");
gotoxy(1,2);cprintf("\xB3");
gotoxy(1,3);cprintf("\xB3");
gotoxy(1,4);cprintf("\xB3");
}

l=l+8;c=0;
}
if(n==nbr)
for(j=0;j<20;j++)
if(!kbhit())
delay(50);
}
}while(!kbhit()&&ok==1);
if(ok==0)
{getch();window(1,1,80,50);textbackground(0);textcolor(7);clrscr();}
else{
window(12,l,65,45);textbackground(0);clrscr();
}

}
void Cadre1(int x1, int y1, int x2, int y2)
{ window(1,1,80,50);
int j;
gotoxy(x1,y1);putch(218);gotoxy(x2,y1);putch(191);
gotoxy(x1,y2);putch(192);gotoxy(x2,y2);putch(217);
for(j=x1+1;j<x2;j++)
{ gotoxy(j,y1);putch(196); gotoxy(j,y2);putch(196);}
for(j=y1+1;j<y2;j++)
{ gotoxy(x1,j);putch(179); gotoxy(x2,j);putch(179);}
}
void Cadre(int x1, int y1, int x2, int y2)
{
int j;
gotoxy(x1,y1);cprintf("\xc9");gotoxy(x2,y1);cprintf("\xbb");
gotoxy(x1,y2);cprintf("\xc8");gotoxy(x2,y2);cprintf("\xbc");
for(j=x1+1;j<x2;j++)
{
gotoxy(j,y1);cprintf("\xcd"); gotoxy(j,y2);cprintf("\xcd");
}
for(j=y1+1;j<y2;j++)
{
gotoxy(x1,j);cprintf("\xba"); gotoxy(x2,j);cprintf("\xba");
}
}

void menu(void)
{
clrscr();
int choix;
textmode(64);
do
{
_setcursortype(_NOCURSOR);
clrscr();
choix=Menu0();
switch(choix)
{
case 0:file_attente();break;
case 1:algo();break;
}
}while(choix!=2);
}
int file_attente_inf(void)
{
int i=0,c=20,l=20,n,j,k;
char choix;

do{
window(20,9,57,29);textbackground(1);clrscr();
switch(i)
{
case 0:
window(24,12,52,16);textbackground(12);clrscr();cprintf("\n \xDB Genere
r file d'attente");
window(24,15,52,19);textbackground(1);clrscr();cprintf("\n \xDB Creer f
ile d'attente");
window(24,18,52,21);textbackground(1);clrscr();cprintf("\n \xDB Supprim
er file d'attente");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB Aff
icher file d'attente");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB Menu pr
ecedent");
window(1,1,80,50);textbackground(0);
for(j=16;j<27;j++)
{
gotoxy(18,j);printf(" ");
}
gotoxy(18,13);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
for(j=14;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
Cadre1(10,35,70,47);
gotoxy(18,35);printf("\xC1");
afficher_generer();
break;
case 1:
window(24,12,52,16);textbackground(1);clrscr();cprintf("\n \xDB Generer
file d'attente");
window(24,15,52,19);textbackground(12);clrscr();cprintf("\n \xDB Creer
file d'attente");
window(24,18,52,21);textbackground(1);clrscr();cprintf("\n \xDB Supprim
er file d'attente");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB Aff
icher file d'attente");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB Menu pr
ecedent");
window(1,1,80,50);
for(j=13;j<27;j++)
{
gotoxy(18,j);printf(" ");
}
for(j=17;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
gotoxy(18,16);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
afficher_creer_file();
break;
case 2:
window(24,12,52,16);textbackground(1);clrscr();cprintf("\n \xDB Generer
file d'attente");
window(24,15,52,19);textbackground(1);clrscr();cprintf("\n \xDB Creer f
ile d'attente");
window(24,18,52,21);textbackground(12);clrscr();cprintf("\n \xDB Suppri
mer file d'attente");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB Aff
icher file d'attente");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB Menu pr
ecedent");
window(1,1,80,50);
for(j=13;j<26;j++)
{
gotoxy(18,j);printf(" ");
}
for(j=20;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
gotoxy(18,19);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
tnt_file(3,38,1);
break;
case 3:
window(24,12,52,16);textbackground(1);clrscr();cprintf("\n \xDB Generer
file d'attente");
window(24,15,52,19);textbackground(1);clrscr();cprintf("\n \xDB Creer f
ile d'attente");
window(24,18,52,21);textbackground(1);clrscr();cprintf("\n \xDB Supprim
er file d'attente");
window(24,21,52,23);textbackground(12);clrscr();cprintf("\n \xDB Af
ficher file d'attente");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB Menu pr
ecedent");
window(1,1,80,50);
for(j=13;j<26;j++)
{
gotoxy(18,j);printf(" ");
}
for(j=23;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
gotoxy(18,22);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
afficher_file();
break;
case 4: window(24,12,52,16);textbackground(1);clrscr();cprintf("\n \xDB
Generer file d'attente");
window(24,15,52,19);textbackground(1);clrscr();cprintf("\n \xDB Creer f
ile d'attente");
window(24,18,52,21);textbackground(1);clrscr();cprintf("\n \xDB Supprim
er file d'attente");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB Aff
icher file d'attente");
window(24,24,52,26);textbackground(12);clrscr();cprintf("\n \xDB Menu p
recedent");
window(1,1,80,50);
for(j=13;j<26;j++)
{
gotoxy(18,j);printf(" ");
}
for(j=26;j<=34;j++)
{
gotoxy(18,j);printf("\xB3");
}
gotoxy(18,25);printf("\xDA\xC4\xC4\xC4\xC4\xC4");
textbackground(0);
do{_setcursortype(_NOCURSOR);
for(k=25;k>10;k--)
{
if(!kbhit())
{
window(k,38,60,44);
gotoxy(1,1);printf(" /\xB3");
gotoxy(1,2);printf(" / \xB3");
gotoxy(1,3);printf(" / \xB3");
gotoxy(1,4);printf(" < \xC3\xC4\xC4\xC4\xC4\xC4\xC4\xC4");
gotoxy(1,5);printf(" \\ \xB3");
gotoxy(1,6);printf(" \\ \xB3");
gotoxy(1,7);printf(" \\\xB3");
for(j=0;j<6;j++)
if(!kbhit())
delay(10);
clrscr();
}
}
}while(!kbhit());
window(1,1,80,50);
break;
}
fflush(stdin);choix=getch();
switch(choix)
{
case 80:
if(i==4) i=0;
else i++;
break;
case 72:
if(i==0) i=4;
else i--;
break;
}
}while(choix!=13);
window(1,1,50,80);textbackground(0);clrscr();textcolor(7);
return i;
}
void file_attente(void)
{
clrscr();
int choix;
textmode(64);
do
{
_setcursortype(_NORMALCURSOR);
clrscr();
choix=file_attente_inf();
switch(choix)
{
case 0:generer();break;
case 1:constuire();break;
case 2:supprimer();break;
case 3:affichage();break;
}
}while(choix!=4);
}
void constuire(void)
{
int i=1,j,l;
window(1,1,80,50);clrscr();
tete=NULL;

do{
clrscr();
window(3,5,38,7);
textbackground(4);
clrscr();
cprintf("\n Entrez le nombre de processus <10");
window(1,1,80,50);
textbackground(0);
Cadre1(41,5,47,7);
gotoxy(43,6);fflush(stdin);scanf("%d",&nbr_p);
}while(nbr_p <= 0 || nbr_p >= 10);
clrscr();
Cadre1(7,3,18,5);Cadre1(18,3,33,5);Cadre1(33,3,48,5);Cadre1(48,3,63,5);
gotoxy(18,3);putch(194);gotoxy(33,3);putch(194);gotoxy(48,3);putch(194);
gotoxy(18,5);putch(197);gotoxy(33,5);putch(197);gotoxy(48,5);putch(197);
gotoxy(8,4);printf("Numero");gotoxy(19,4);printf("Date arrive");
gotoxy(34,4);printf("Tmp execution");gotoxy(49,4);printf("Temps E/S");
gotoxy(7,5);putch(195);gotoxy(63,5);putch(180);
for(l=6;l<=(nbr_p*2)+6;l++)
{
gotoxy(7,l);putch(179);gotoxy(18,l);putch(179);gotoxy(33,l);putch(179);
gotoxy(48,l);putch(179);gotoxy(63,l);putch(179);
}
Cadre1(7,(nbr_p*2)+6,63,(nbr_p*2)+6);
gotoxy(18,(nbr_p*2)+6);putch(193);gotoxy(33,(nbr_p*2)+6);putch(193);
gotoxy(48,(nbr_p*2)+6);putch(193);
j=7;
while(i<=nbr_p)
{
p=(processus*)malloc(sizeof(processus));
if(p==NULL)
{
triangle();
textcolor(RED+BLINK);
gotoxy(30,31);cprintf("PAS DE MEMOIRE");sleep(1)
;
textcolor(7);
}
else
{
p->num=i;

gotoxy(9,j);printf("%d",p->num);
gotoxy(21,j);putch(175);printf(" ");scanf("%d",&p->DA);gotoxy(21,j);pr
intf(" ");
gotoxy(36,j); putch(175);printf(" ");scanf("%d",&p->TE)
;gotoxy(36,j);printf(" ");
gotoxy(51,j);putch(175);printf(" ");scanf("%d",&p->TES)
;gotoxy(51,j);printf(" ");

j=j+2;
if (tete==NULL)
{
tete=p;
p->suivant=NULL;
dernier=p;
}
else
{
dernier->suivant=p;
p->suivant=NULL;
dernier=p;
}
}
i++;
}
afficher_liste(nbr_p,nbr_p+16,0);
}
//generer file d'attente
void generer(void)
{
int i=1;
char rep=NULL;
tete=NULL;
randomize();
do{
clrscr();
window(3,5,38,7);
textbackground(4);
clrscr();
cprintf("\n Entrez le nombre de processus <10");
window(1,1,80,50);
textbackground(0);
Cadre1(41,5,47,7);
gotoxy(43,6);fflush(stdin);scanf("%d",&nbr_p);
}while(nbr_p <= 0 || nbr_p >= 10);
window(1,1,80,50);
do{
textcolor(14);
gotoxy(37,8);cprintf("Confirmer O/N");rep=getch();
}while(rep!='o'&&rep!='O'&&rep!='n'&&rep!='N');
textcolor(7);
if(rep=='o'||rep=='O')
{
gotoxy(55,8);textcolor(2);cprintf("OUI");
while(i<=nbr_p)
{
p=(processus*)malloc(sizeof(processus));
if(p==NULL)
{
triangle();
textcolor(RED+BLINK);
gotoxy(30,31);cprintf("PAS DE MEMOIRE");sleep(2)
;
textcolor(7);
}
else
{
p->num=i;
p->DA=random();
p->TE=random();
p->TES=random();
if (tete==NULL)
{
tete=p;
p->suivant=NULL;
dernier=p;
}
else
{
dernier->suivant=p;
p->suivant=NULL;
dernier=p;
}
}
i++;
}
afficher_liste(nbr_p,15,0);
}
else{gotoxy(55,8);textcolor(RED);cprintf("NON");textcolor(7);delay(200);}
}
//generer nombre
int random (void)
{
return (0+ (rand () % (9)));
}
//afficher file d'attente
void affichage()
{
processus *pr;
int i=7;
char val;
pr=tete;
_setcursortype(_NOCURSOR);
clrscr();

while(pr!=NULL)
{
gotoxy(7,i-1);putch(179);gotoxy(7,i);putch(179);gotoxy(10,i);pri
ntf("%d",pr->num);
gotoxy(18,i-1);putch(179);gotoxy(18,i);putch(179);gotoxy(22,i);p
rintf("%d",pr->DA);
gotoxy(33,i-1);putch(179);gotoxy(33,i);putch(179);gotoxy(38,i);p
rintf("%d",pr->TE);
gotoxy(48,i-1);putch(179);gotoxy(48,i);putch(179);gotoxy(53,i);p
rintf("%d",pr->TES);
gotoxy(63,i-1);putch(179);gotoxy(63,i);putch(179);
pr=pr->suivant;
i=i+2;
}
if(i==7)
{
triangle();
textcolor(RED+BLINK);
gotoxy(37,29);cprintf("FILE VIDE");delay(1000);g
etch();
textcolor(7);
}
else{
Cadre1(7,3,18,5);Cadre1(18,3,33,5);Cadre1(33,3,48,5);Cadre1(48,3,63,5);
gotoxy(18,3);putch(194);gotoxy(33,3);putch(194);gotoxy(48,3);putch(194);
gotoxy(18,5);putch(197);gotoxy(33,5);putch(197);gotoxy(48,5);putch(197);
gotoxy(8,4);printf("Numero");gotoxy(19,4);printf("Date arrive");
gotoxy(34,4);printf("Tmp execution");gotoxy(49,4);printf("Temps E/S");
gotoxy(7,5);putch(195);gotoxy(63,5);putch(180);
Cadre1(7,i,63,i);
gotoxy(18,i);putch(193);gotoxy(33,i);putch(193);gotoxy(48,i);putch(193);
gotoxy(7,i-1);putch(179);gotoxy(18,i-1);putch(179);gotoxy(33,i-1);putch(
179);
gotoxy(48,i-1);putch(179);gotoxy(63,i-1);putch(179);
//afficher les tries
afficher_trie();
do{
fflush(stdin);val=getch();
switch(val)
{
case 59:{
trie_da(); //F1
pr=tete;
i=7;
while(pr!=NULL)
{
gotoxy(7,i-1);putch(179);gotoxy(7,i);putch(179);gotoxy(10,i);pri
ntf("%d",pr->num);
gotoxy(18,i-1);putch(179);gotoxy(18,i);putch(179);gotoxy(22,i);p
rintf("%d",pr->DA);
gotoxy(33,i-1);putch(179);gotoxy(33,i);putch(179);gotoxy(38,i);p
rintf("%d",pr->TE);
gotoxy(48,i-1);putch(179);gotoxy(48,i);putch(179);gotoxy(53,i);p
rintf("%d",pr->TES);
gotoxy(63,i-1);putch(179);gotoxy(63,i);putch(179);
pr=pr->suivant;
i=i+2;
}
}break;
case 60:{
trie_te(); //F2
pr=tete;i=7;
while(pr!=NULL)
{
gotoxy(7,i-1);putch(179);gotoxy(7,i);putch(179);gotoxy(10,i);pri
ntf("%d",pr->num);
gotoxy(18,i-1);putch(179);gotoxy(18,i);putch(179);gotoxy(22,i);p
rintf("%d",pr->DA);
gotoxy(33,i-1);putch(179);gotoxy(33,i);putch(179);gotoxy(38,i);p
rintf("%d",pr->TE);
gotoxy(48,i-1);putch(179);gotoxy(48,i);putch(179);gotoxy(53,i);p
rintf("%d",pr->TES);
gotoxy(63,i-1);putch(179);gotoxy(63,i);putch(179);
pr=pr->suivant;
i=i+2;
}
}break;
}
}while(val!=27);
}
}
//supprimer file d'attente
void supprimer()
{
char rep;
window(1,1,80,50);
clrscr();
window(3,5,45,7);textbackground(4);clrscr();
cprintf("\nConfirmez vous la suppression ? (O/N) ");
do
{
fflush(stdin);rep=getch();
}while(rep!='o' && rep!= 'O' && rep!= 'n' && rep!= 'N');
if(rep=='O'||rep=='o')
{
textcolor(6+128);
cprintf("Oui !");sleep(1);
free(p);
tete=NULL;
textcolor(7);
}
else
{
textcolor(6+128);
cprintf("Non !");sleep(1);
}
textcolor(7);
textbackground(0);
window(1,1,80,50);
textcolor(7);
}
//
int Menu1(void)
{
int i=0,c=20,l=20,n,j;
char choix;

do{
window(20,15,57,29);textbackground(1);clrscr();_setcursortype(_NOCURSOR);
switch(i)
{
case 0:
window(24,18,52,22);textbackground(12);clrscr();cprintf("\n \xDB Tourni
quet avec FIFO");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB SRT ave
c FIFO");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB Menu pr
ecedent");
window(1,1,80,50);textbackground(0);
break;
case 1:window(24,18,52,22);textbackground(1);clrscr();cprintf("\n \xDB Tourniq
uet avec FIFO");
window(24,21,52,23);textbackground(12);clrscr();cprintf("\n \xDB SRT av
ec FIFO");
window(24,24,52,26);textbackground(1);clrscr();cprintf("\n \xDB Menu pr
ecedent");
window(1,1,80,50);

break;
case 2:window(24,18,52,22);textbackground(1);clrscr();cprintf("\n \xDB Tourniq
uet avec FIFO");
window(24,21,52,23);textbackground(1);clrscr();cprintf("\n \xDB SRT ave
c FIFO");
window(24,24,52,26);textbackground(12);clrscr();cprintf("\n \xDB Menu p
recedent");
window(1,1,80,50);

break;
}
fflush(stdin);choix=getch();
switch(choix)
{
case 80:
if(i==2) i=0;
else i++;
break;
case 72:
if(i==0) i=2;
else i--;
break;
}
}while(choix!=13);
window(1,1,50,80);textbackground(0);clrscr();textcolor(7);
return i;
}
void algo()
{
clrscr();
char choix;
textmode(64);
do
{
_setcursortype(_NORMALCURSOR);
clrscr();
choix=Menu1();
switch(choix)
{
case 0:tourniquet();break;
case 1:srt();break;
}
}while(choix!=2);
}
//trie date d'arrivé
void trie_da()
{
processus *p1,*min,*p2;
int t;
p1=tete;
while(p1!=NULL)
{
p2=p1;
min=p2;
while(p2!=NULL)
{
if(min->DA > p2->DA)
{
min=p2;
}
p2=p2->suivant;
}
t=p1->num;
p1->num=min->num;
min->num=t;
t=p1->DA;
p1->DA=min->DA;
min->DA=t;
t=p1->TE;
p1->TE=min->TE;
min->TE=t;
t=p1->TES;
p1->TES=min->TES;
min->TES=t;
p1=p1->suivant;
}
}
//trie temps d'execution
void trie_te()
{
processus *p1,*min,*p2;
int t,i=0;
p1=tete;
while(p1!=NULL)
{
p2=p1;
min=p2;
while(p2!=NULL)
{
if(min->TE > p2->TE)
{
min=p2;
}
p2=p2->suivant;
}
if(i==0){deb=min->num;i++;}
t=p1->num;
p1->num=min->num;
min->num=t;
t=p1->DA;
p1->DA=min->DA;
min->DA=t;
t=p1->TE;
p1->TE=min->TE;
min->TE=t;
t=p1->TES;
p1->TES=min->TES;
min->TES=t;
p1=p1->suivant;
}
}

//affichage trie
void afficher_trie()
{
int r;

window(25,36,53,38);
textbackground(4);
clrscr();
cprintf("\n Trier la file d'attente par");
textbackground(0);
window(1,1,80,50);
gotoxy(39,39);putch(194);gotoxy(39,40);putch(179);
gotoxy(5,41);
for(r=0;r<68;r++) putch(196);
gotoxy(5,41);putch(218);
gotoxy(73,41);putch(191);
gotoxy(39,41);putch(197);
for(r=42;r<50;r++)
{
gotoxy(5,r);putch(179);
gotoxy(73,r);putch(179);
gotoxy(39,r);putch(179);
}
window(1,50,80,50);
textbackground(7);
clrscr();
textcolor(4);gotoxy(2,1);cprintf("F1 ");textcolor(0);cprintf("DA");
textcolor(4);gotoxy(36,1);cprintf("F2 ");textcolor(0);cprintf("TE");
textcolor(4);gotoxy(68,1);cprintf("ESC ");textcolor(0);cprintf("MENU");
window(1,1,80,50);
textcolor(7);
textbackground(0);
}
void triangle()
{
_setcursortype(_NOCURSOR);
clrscr();

printf("\n\n\n\n\n");
printf(" ^\n");
printf(" /\xDB\\\n");
printf(" /\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\\\n")
;
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xD
B\\\n");
printf(" /\xDB\xDB\xDB \xDB\xDB\xDB\
\\n");
printf(" /\xDB\xDB\xDB\xDB \xDB\xDB\x
DB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB \xDB\xD
B\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB \xDB
\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB \
xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB
\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\x
DB \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xD
B\xDB \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB
\xDB\xDB \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\
xDB\xDB\xDB \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\x
DB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\
\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xD
B\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xD
B\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB
\xDB\xDB\xDB\xDB\xDB \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\
xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\
xDB\xDB\xDB\xDB\xDB\xDB \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\x
DB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\x
DB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\x
DB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
printf(" /\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xD
B\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xD
B\xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\\\n");
}
void emsi()
{
int i;
clrscr();
Entete();
window(23,7,54,32);
textbackground(15);
clrscr();
window(1,1,80,50);
textbackground(15);
textcolor(RED);
gotoxy(48,20);cprintf("Û");
gotoxy(47,21);cprintf("ÞÛÝ");
gotoxy(48,22);cprintf("Û");
window(27,24,50,31);
textbackground(0);
clrscr();
textcolor(7);
gotoxy(2,2);cprintf("ÛÛÛÛÛ Û Û ÛÛÛÝ Û ");
gotoxy(2,3);cprintf("Û ÛÛ ÛÛ Þ Û ");
gotoxy(2,4);cprintf("ÛÛÛÛÛ Û Ý Þ Û ÛÛ Û ");
gotoxy(2,5);cprintf("Û Û Û Û Û Û Û ");
gotoxy(2,6);cprintf("Û Û Þ Ý Û Ý Û ");
gotoxy(2,7);cprintf("ÛÛÛÛÛ Û Û Û ÞÛÛÛ Û ");
window(1,1,80,50);
window(27,8,46,24);

textcolor(2);
textbackground(7);
cprintf(" H.\n");
cprintf("\r M MH H .MM\n");
cprintf("\r .M HH HM. M \n");
cprintf("\r HM MM .M.:MMMM\n");
cprintf("\r HMMMMMMMMMMMMMM \n");
cprintf("\r HMMMMMMMMMMMMMMMM \n");
cprintf("\r MMMMMMMMMMMMMMMMMH\n");
cprintf("\r MMMMMMMMMMMMMMMMMM\n");
cprintf("\r MMMMMMMMMMM HMMMM \n");
cprintf("\r M:MMMMMMMMMHHMMH \n");
cprintf("\r MHMMMMMMHMM MMM. \n");
cprintf("\r M:MMMMM MM MHM. \n");
cprintf("\r H MMHMM MM M.M \n");
cprintf("\r MM.MM MM MHM \n");
cprintf("\r MM MM HM MM \n");
cprintf(" \r MM MM M HM \n");
textbackground(0);cprintf(" \r H H .M H ");
textcolor(7);

delay(700);
window(1,1,80,50);

_setcursortype(_NOCURSOR);
textcolor(3);gotoxy(35,43);cprintf("ATTENDEZ SVP");textcolor(7);
for(i=25;i<53;i++)
{ window(1,1,80,50);Entete();
window(25,39,i,40);
textbackground(RED);
clrscr();

window(1,1,80,50);
window(22,41,i,45);
textbackground(0);
clrscr();
gotoxy(i-24,1);printf("ÜÜ");
gotoxy(i-24,2);printf("ÞøÛßß");
gotoxy(i-24,3);printf("ÞÛ ");
if(i>=35&&i<47){
textcolor(RED); gotoxy(i-22,3);cprintf("Ý");textcolor(7);
}
gotoxy(i-23,3);cprintf("Û");
if(i%2==0)
{gotoxy(i-24,4);printf("ÞÛÛÜÜ"); }
else{
gotoxy(i-24,4);printf("ÞÛÛßß");
}
gotoxy(i-24,5);printf(" ß");
delay(180);
window(1,1,80,50);
}
textbackground(0);
delay(500);
window(1,1,80,50);
textbackground(0);clrscr();
textcolor(7);
menu();
}

void matrice()
{
int i,j;
for(i=0;i<40;i++)
for(j=0;j<70;j++)
M[i][j]=0;
}
////////////algo srt
void srt()
{
int j,k,i;
int saveTES[10],saveTE[10];
processus *pr=tete;
i=1;
while(pr!=NULL)
{
saveTES[i]=pr->TES;
saveTE[i]=pr->TE;
i++;
pr=pr->suivant;
}
matrice();
for(i=0;i<70;i++)
{
trie_te();
pr=tete;
while(pr!=NULL)
{
if(pr->DA<=i)
{
if(pr->TE>0)
{
//élu
if(elu(i)==0)
{
M[(pr->num-1)*4][i]=1;
pr->TE--;
}
else
//pret
M[(pr->num-1)*4+1][i]=1;
}
else
if( pr->TES >0&&M[(pr->num-1)*4+2][i]==0
)
//E/S
if( TES(i)==0)
{
M[((pr->num)-1)*4+2][i]=
1;
pr->TES--;
}
else
//BloK
M[(pr->num-1)*4+3][i]=1;
if(pr->TES==0&&pr->TE==0)
{
pr->TES=saveTES[pr->num];
pr->TE=saveTE[pr->num];
}
}
pr=pr->suivant;
}
}
pr=tete;
while(pr!=NULL)
{
pr->TES=saveTES[pr->num];
pr->TE=saveTE[pr->num];
pr=pr->suivant;
}
trie_da();
affichage_srt();
}
///algo tourniquet
void tourniquet()
{
int i,j,existe=0,k,l=1,ll,Qum=-1;
int saveTES[10],saveTE[10],Q[10];
processus *pr=tete,*pr2=tete;
if(nbr_p==0)
{
triangle();
textcolor(RED+BLINK);
gotoxy(37,29);cprintf("FILE VIDE");delay(1000);getch();
textcolor(7);
}
else{
do{
clrscr();
window(3,5,38,7);
textbackground(4);
clrscr();
cprintf("\n Entrez le Quantum >0");
window(1,1,80,50);
textbackground(0);
Cadre1(41,5,47,7);
gotoxy(43,6);scanf("%d[0-9]",&Qum);
}while(Qum < 0 || Qum==-1);
for(i=0;i<=nbr_p;i++)
Q[i]=Qum;
while(pr2!=NULL)
{
saveTES[l]=pr2->TES;
saveTE[l]=pr2->TE;
l++;pr2=pr2->suivant;
}
matrice();
for(i=0;i<70;i++)
{
pr=tete;
while(pr!=NULL)
{
if(pr->DA<=i)
{
//élu
if(pr->TE>0 && elu(i)==0 && Q[pr->num]!=0)
{
M[(pr->num-1)*4][i]=1;
pr->TE--;
existe=1;
Q[pr->num]--;
}
else
//pret
if(pr->TE > 0 && (Q[pr->num]==0) || (elu(i)==1
&& M[(pr->num-1)*4][i]==0))
M[(pr->num-1)*4+1][i]=1;
else
//E/S
if(pr->TE==0 && TES(i)==0 && pr->TES >0 && M[(pr
->num-1)*4][i]==0)
{
M[((pr->num)-1)*4+2][i]=1;
pr->TES--;
}
else
//BloK
if((pr->TE==0) && (TES(i)==1)&&(pr->TES > 0)&& M
[(pr->num-1)*4+2][i]==0)
M[(pr->num-1)*4+3][i]=1;
if(pr->TES==0&&pr->TE==0)
{
pr->TES=saveTES[pr->num];
pr->TE=saveTE[pr->num];
ll=1;
}
//Q[i]--;
if(pr->TE==0)
Q[pr->num]=Qum;
if(pr->num==nbr_p&&Q[pr->num]==0)
for(k=0;k<=nbr_p;k++)
Q[k]=Qum;
}
pr=pr->suivant;
}
}
pr2=tete;
l=1;
while(pr2!=NULL)
{
pr2->TES=saveTES[pr2->num];
pr2->TE=saveTE[pr2->num];
l++;pr2=pr2->suivant;
}
affichage_srt();
}
}

int elu(int i)
{
int j;
for(j=0;j<40;j=j+4)
if(M[j][i]==1)
return 1;
return 0;
}
int TES(int i)
{
int j;
for(j=2;j<40;j=j+4)
if(M[j][i]==1)
return 1;
return 0;
}

void trie_da_te()
{
processus *p1,*min,*p2;
int t,i=0;
p1=tete;
while(p1!=NULL)
{
p2=p1;
min=p2;
while(p2!=NULL)
{
if(min->DA > p2->DA)
min=p2;
else
if(min->DA==p2->DA)
if(min->TE>p2->TE)
min=p2;
p2=p2->suivant;
}
if(i==0){deb=min->num;i++;}
t=p1->num;
p1->num=min->num;
min->num=t;
t=p1->DA;
p1->DA=min->DA;
min->DA=t;
t=p1->TE;
p1->TE=min->TE;
min->TE=t;
t=p1->TES;
p1->TES=min->TES;
min->TES=t;
p1=p1->suivant;
}
}
//aficher matrice
void affichage_srt()
{
int i,j,k,l,r,n,moin;
char val;
int rtmp =0,ntmp;
r=0;
n=nbr_p/5;
ntmp=n;
if(nbr_p==5)
n--;
do{
clrscr();
k=1;l=4;
for(i=0;i<=(5)*4;i++)
{

for(j=11;j<80;j=j+2)
{
gotoxy(j,k);putch(196);gotoxy(j-1,k);putch(196);gotoxy(j+1,k);putch(196);
gotoxy(6,k);putch(197);gotoxy(6,k+1);putch(179);
if(j>8)
{gotoxy(j,k);putch(197);gotoxy(j,k+1);putch(179);}
}
k=k+2;
}
for(i=3;i<=(5)*4*2+2;i++)
{gotoxy(1,i);printf(" ");
if(i%2)putch(195);
}
Cadre(1,1,80,k);
for(i=0;i<80;i++)
{gotoxy(i,k+1);printf(" ");}
for(i=3;i<(5)*4*2+3;i=i+2)
{gotoxy(7,i);putch(196);putch(196);putch(196);}
for(i=4;i<(5)*4*2+3;i=i+8)
{gotoxy(7,i);printf("elu");
gotoxy(7,i+2);printf("pret");
gotoxy(7,i+4);printf("E\\S");
gotoxy(7,i+6);printf("BLK");
}
for(i=3;i<(5)*4*2+3;i=i+8)
{gotoxy(1,i);putch(199);putch(196);putch(196);putch(196);putch(196);putch(197);}
for(i=11;i<80;i=i+2)
{gotoxy(i,1);putch(209);}
gotoxy(6,1);putch(209);
for(i=11;i<80;i=i+2)
{gotoxy(i,(5)*4*2+3);putch(207);}
gotoxy(6,(5)*4*2+3);putch(207);
gotoxy(1,(5)*4*2+3);putch(200);

k=12;
for(i=0;i<(5)*4;i++)
{
for(j=0;j<34;j++)
{
gotoxy(k,l);

if(M[i+(r*20)][j]==1) {textcolor(2);putch(219);textcolor(7);}
k=k+2;
}l=l+2;k=12;
}
for(i=1,l=7;i<=(5);i++,l=l+8)
{ gotoxy(3,l);textcolor(4);cprintf("P%d",i+r*5);textcolor(7);}
textcolor(4);gotoxy(2,2);cprintf("Proc");
textcolor(3);gotoxy(7,2);printf("Etat");
for(i=12,l=0;i<=45&&l<=9;i=i+2,l++)
{gotoxy(i,2);cprintf("%d",l);}
gotoxy(i,2);cprintf(".");i=i+2;
gotoxy(i,2);cprintf(".");i=i+2;
gotoxy(i,2);cprintf(".");i=i+2;
textcolor(7);
moin=((r+1)*5)-nbr_p;
if((nbr_p%5)!=0&&n==(0))
{
for(i=((5-moin)*8)+4;i<45;i++)
for(j=0;j<80;j++)
{
gotoxy(j,i);printf(" ");
}
for(j=11;j<80;j=j+2)
{gotoxy(j,((5-moin)*8)+4);putch(207);gotoxy(j-1,((5-moin)*8)+4);putch(205);}
gotoxy(1,((5-moin)*8)+4);putch(200);gotoxy(80,((5-moin)*8)+4);putch(188);
for(j=2;j<10;j++)
{
if(j==6)
{gotoxy(j,((5-moin)*8)+4);putch(207);}
else {gotoxy(j,((5-moin)*8)+4);putch(205);}
}
}

window(1,50,80,50);
textbackground(7);
textcolor(4);
clrscr();
cprintf(" S/s SUIVANT P/p PRECEDENT");
gotoxy(71,1);cprintf("ESC MENU");
textbackground(0);
textcolor(7);
window(1,1,80,50);
do{
fflush(stdin);val=getch();
}while(val!=27 && val!='P' && val!='S' && val!='p' && val!='s' );
switch(val)
{
case '27': n=(-1);
break;
case 'S': break;
case 'P': n=n+2;r=r-2;
break;
case 's': break;
case 'p': n=n+2;r=r-2;
break;
}
n--;
r++;
}while(n>=0&&r>=0);

}
void afficher_generer()
{
int m[20][30],i,j,k=0,cpt;
randomize();
window(16,42,30,45);textbackground(0);clrscr();
gotoxy(1,1);printf("\xBF");gotoxy(14,1);printf("\xDA");
gotoxy(1,2);printf("\xB3");gotoxy(14,2);printf("\xB3");
gotoxy(1,3);printf("\xB3");gotoxy(14,3);printf("\xB3");
gotoxy(1,4);printf("\xC0\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xC4\xD9");
Cadre1(49,37,65,42);
gotoxy(49,38);printf("\xF5");
gotoxy(49,39);printf(" ");
gotoxy(49,40);printf("\xF4");
gotoxy(21,38);printf("\xDA\xC4\xC4\xC4\xC4\xC4\xC4");
gotoxy(21,39);printf("\xB3");
gotoxy(24,40);printf("\xDA\xC4\xC4\xC4");
gotoxy(24,40);printf("\xA9");
for(i=28;i<48;i++)
{
gotoxy(i,38);printf("\xC4");
gotoxy(i,40);printf("\xC4");
}
gotoxy(i,38);printf("\xD9");
gotoxy(i,40);printf("\xBF");

while(!kbhit())
{
window(50,38,64,41);textbackground(0);clrscr();
window(1,1,50,80);
for(i=0;i<4;i++)
for(j=0;j<16;j++)
m[i][j]=random(9);
for(i=0;i<4;i++)
for(j=0;j<14;j++)
{gotoxy(j+1,i+1);textcolor(random(14));cprintf("%d",m[i][j]);}
window(1,1,80,50);
for(i=46;i>20;i=i-2)
{gotoxy(i,39);printf("%d",m[2][4]);
gotoxy(i+2,39);printf(" ");
cpt=0;
while(!kbhit()&&cpt<10)
{delay(5);cpt++;}
}
gotoxy(22,39);printf(" ");
gotoxy(22,41);printf("%d",m[2][4]);delay(50);
gotoxy(22,41);printf(" ");
gotoxy(17,43);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
gotoxy(17,44);printf("\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0\xB0");
delay(10);delay(10);delay(10);delay(10);delay(10);
gotoxy(17,43);printf(" ");
gotoxy(17,44);printf(" ");
cpt=0;
while(!kbhit()&&cpt<10)
{delay(5);cpt++;}
}
window(11,36,69,46);textbackground(0);clrscr();window(1,1,80,50);textcolor(7);
}

void tnt_file(int nbr,int l,int ok)


{
int n,j,c,milliseconde=60,sec=4,i;
if(nbr_p!=0&&ok!=1)
nbr=nbr_p;
window(11,36,69,46);textbackground(0);clrscr();
for(n=1,c=1;n<=nbr;n++,c++)
{
window(c*18,l,(c*18)+8,l+4);textbackground(6);clrscr();
gotoxy(4,3);textcolor(0);cprintf("P%d",n);textcolor(7);
if(c==1&&n==1)
{textcolor(RED+128);gotoxy(1,2);cprintf("\xDE");
gotoxy(1,3);cprintf("\xDE");
gotoxy(1,4);cprintf("\xDE");
window(12,l+1,17,l+1);textbackground(0);textcolor(RED);putch(254);cpri
ntf("TETE");
}

if(n!=nbr_p&&n%3!=0){
window((c*18)+9,l+1,(c*18)+20,l+5);
textcolor(2);textbackground(0);
gotoxy(1,1);cprintf("\xB8");
gotoxy(1,3);cprintf("\xBE");
gotoxy(1,2);cprintf("\xC6");cprintf("\xAF");cprintf("\xAF");
cprintf("\xAF");
cprintf("\xAF");cprintf("\xAF");cprintf("\xAF");
cprintf("\xAF");cprintf("\xB4");
gotoxy(9,1);cprintf("\xD5");
gotoxy(9,3);cprintf("\xD4");
}
if(n%3==0&&ok!=1)
{window((c*18)+11,l+1,(c*18)+20,l+7);textbackground(0);clrscr(
);
gotoxy(1,2);printf("\xBF");
gotoxy(1,3);printf("\xB3");
gotoxy(1,4);printf("\xB3");
gotoxy(1,5);printf("\xB3");
gotoxy(1,6);printf("\xB3");
gotoxy(1,6);printf("\xD9");
window(18,l+6,50,l+6);
if(n!=nbr_p&&ok!=1)
for(j=1;j<48;j++)
printf("\xC4");
if(ok!=1){
window(16,l+6,17,l+12);textbackground(0);clrscr();
gotoxy(1,5);cprintf("\xB3\xD5");
gotoxy(1,6);cprintf("\xC0\xB4");
gotoxy(2,7);cprintf("\xD4");
gotoxy(1,1);cprintf("\xDA\xC4");
gotoxy(1,2);cprintf("\xB3");
gotoxy(1,3);cprintf("\xB3");
gotoxy(1,4);cprintf("\xB3");
}

l=l+8;c=0;
}

}
while(!kbhit()&&sec!=-1)
{
/////////////////////////////////////////////
window(11,46,18,46);textbackground(3);clrscr();textcolor(0);
gotoxy(2,1);cprintf("T N T ");textcolor(0+128);cprintf("\xFE")
;
window(11,44,18,45);clrscr();textcolor(RED);
clrscr();cprintf("00:0%d:%d",sec,milliseconde);
delay(16);milliseconde--;
if(milliseconde==0&&sec>0){sec--;milliseconde=60;}
if(milliseconde==0&&sec==0)
{
clrscr();
textcolor(RED+BLINK);cprintf("00:00:00");
if(!kbhit())delay(50); if(!kbhit())delay(50); if(!kbhit())delay(50); if(!kbhi
t())delay(50);
if(!kbhit())delay(50); if(!kbhit())delay(50); if(!kbhit())delay(50); if(!kbhi
t())delay(50);
if(!kbhit())delay(50); if(!kbhit())delay(50); if(!kbhit())delay(50); if(!kbhi
t())delay(50);
window(11,44,18,46);textbackground(0);clrscr();textcolor(RED);
for(i=0;i<30;i++)
{
gotoxy(2,2);cprintf("BOOMMM");delay(20);
}
for(i=0;i<2;i++)
{
window(11,36,69,46);textbackground(7);clrscr();delay(20);textbackground(0);cl
rscr();delay(50);
}

milliseconde=60;sec=-1;
}
}
window(11,36,69,46);textbackground(0);clrscr(); textcolor(7);
}

void afficher_file()
{
int cpt=3,i,j=0;

window(30,36,44,38);textbackground(0);clrscr();
gotoxy(1,1);printf("\\ /");
gotoxy(1,2);printf(" \\ /");
gotoxy(1,3);printf(" \\ /");

while(!kbhit())
{

window(30,39,42,45);textbackground(7);clrscr();
window(31,40,40,44);textbackground(0);clrscr();
gotoxy(2,2);printf("DA : %d",random(20));
gotoxy(2,3);printf("TE : %d",random(20));
gotoxy(2,4);printf("E/S: %d",random(20));
window(42,39,44,45);textbackground(3);clrscr();
gotoxy(3,1);textcolor(RED+BLINK);cprintf("\xF9");textcolor(RED);
gotoxy(1,2);cprintf("P%d",j);
textcolor(7);
textcolor(0);gotoxy(1,3);cprintf("\xB0\xB0\xB0");
gotoxy(1,3);cprintf("\xB1\xB1\xB1");
gotoxy(1,4);cprintf("\xB1\xB1\xB1");
gotoxy(2,7);textcolor(RED);cprintf("\xDF");textcolor(7);
for(i=0;i<100;i++)
if(!kbhit())
delay(10);
cpt++;j++;

}
window(11,36,69,46);textbackground(0);textcolor(7);clrscr();
window(1,1,80,50);

}
void afficher_creer_file()
{
int n,j,c,milliseconde=60,sec=4,i,l=38;

window(11,36,69,46);textbackground(0);clrscr();
for(n=1,c=1;n<=3;n++,c++)
{
window((c*18)+2,l,(c*18)+10,l+4);textbackground(0);clrscr();textcolor(7);
gotoxy(1,2);cprintf("DA: ");
for(i=0;i<10;i++)
if(!kbhit())delay(10);
cprintf("%d",random(40));
gotoxy(1,3);cprintf("TE: ");
for(i=0;i<10;i++)
if(!kbhit())delay(10);
cprintf("%d",random(40));
gotoxy(1,4);cprintf("E/S:");
for(i=0;i<10;i++)
if(!kbhit())delay(10);
cprintf("%d",random(40));
for(i=0;i<100;i++)
if(!kbhit())delay(10);
clrscr();
window(c*18,l,(c*18)+8,l+4);textbackground(6);clrscr();
gotoxy(4,3);textcolor(0);cprintf("P%d",n);textcolor(7);
if(c==1&&n==1)
{textcolor(RED+128);gotoxy(1,2);cprintf("\xDE");
gotoxy(1,3);cprintf("\xDE");
gotoxy(1,4);cprintf("\xDE");
window(12,l+1,17,l+1);textbackground(0);textcolor(RED);putch(254);cpri
ntf("TETE");
}

if(n%3!=0){
window((c*18)+9,l+1,(c*18)+20,l+5);
textcolor(2);textbackground(0);
gotoxy(1,1);cprintf("\xB8");
gotoxy(1,3);cprintf("\xBE");
gotoxy(1,2);cprintf("\xC6");cprintf("\xAF");cprintf("\xAF");
cprintf("\xAF");
cprintf("\xAF");cprintf("\xAF");cprintf("\xAF");
cprintf("\xAF");cprintf("\xB4");
gotoxy(9,1);cprintf("\xD5");
gotoxy(9,3);cprintf("\xD4");
}

}
while(!kbhit())delay(10);
window(11,36,69,46);textbackground(0);clrscr(); textcolor(7);window(1,1,80,50);
}