Vous êtes sur la page 1sur 2

#include<stdio.

h>
#include<stdlib.h>
#include<time.h>
#define PROCESSES 9
#define NEWLINE '\n'

int main(){
printf("PID \t No. of bursts \t Arrival time \t\t\t Duration \n");
srand(time(NULL));
for(int i = 0; i<=PROCESSES; i++){
printf("%d\t\t",i);

int bursts = rand() % 10 + 1;

printf("%d\t\t",bursts);

int arrival;

if( i == 0){
arrival = 0;
}else{
arrival = arrival + (rand() % 5);
}
printf("%d\t\t", arrival);

int totalBursts = bursts*2 + 1;


int cpuIOburst[totalBursts];
for(int b = 0; b<totalBursts; b++){
cpuIOburst[b] = rand()%10 + 1;
if(cpuIOburst[b] < 10){
printf("%d ",cpuIOburst[b]);
}else{
printf("%d ",cpuIOburst[b]);
}

printf("%c",NEWLINE);
}
return(0);
}

Vous aimerez peut-être aussi