-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfcfs.cpp
More file actions
36 lines (35 loc) · 755 Bytes
/
fcfs.cpp
File metadata and controls
36 lines (35 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> p(n), wt(n), bt(n),tat(n),ct(n);
for (int i=0;i<n; i++){
cout<<"enter burst time of " <<i+1<<"th process ";
cin>>bt[i];
p[i]=i+1;
}
wt[0]=0;
ct[0]=bt[0];
tat[0]=ct[0];
for(int i=1;i<n;i++){
wt[i]=wt[i-1] + bt[i-1];
ct[i]=bt[i]+wt[i];
tat[i]=ct[i]-p[i];
}
cout<<"waiting time: ";
for(int i=0;i<n; i++){
cout <<wt[i]<<" ";
}
cout<<endl;
cout<<"turn around time: ";
for(int i=0;i<n; i++){
cout <<tat[i]<<" ";
}
cout<<endl;
cout<<"complete time: ";
for(int i=0;i<n; i++){
cout <<ct[i]<<" ";
}
cout<<endl;
}