Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- void main(){
- char pid[12], at[12]={0, 0, 2, 2, 2, 10, 10, 15, 20, 30, 40, 40}, et[12]={10,3,2,1,4,5,7,8,10,9,3,2}, ct[12], wt[12], tt[12];
- int i, time, N=12, sumWT=0, sumTT=0;
- float avgWT, avgTT;
- clrscr();
- for(i = 0; i < N; i++) pid[i] = i+ 65;
- time = 0;
- for(i = 0;;){
- if(time >= at[i]){
- ct[i] = time + et[i];
- time = ct[i];
- wt[i] = ct[i] - (at[i] + et[i]);
- tt[i] = ct[i] - at[i];
- i++;
- }
- else time++;
- if(i == N) break;
- }
- printf("pid\tAT\tET\tCT\t\WT\tTT\n");
- for(i = 0; i < N; i++){
- printf("%c\t%d\t%d\t%d\t%d\t%d\n", pid[i], at[i], et[i], ct[i], wt[i], tt[i]);
- sumWT+=wt[i];
- sumTT+=tt[i];
- }
- avgWT = sumWT/12.0;
- avgTT = sumTT/12.0;
- printf("\nThe average waiting time is %.2f \n", avgWT);
- printf("The average turn-around time is %.2f\n", avgTT);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement