disk scheduling SSTF in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

disk scheduling SSTF in c++

im trying to implement sstf in c++,but im stuck,could you help me complete it? #include<iostream> #include<math.h> using namespace std; int main() { int h,i,min,p,s; int a[8],b[8]; cout<<"The number of requests is = 100(from 0-99)"; cout<<"\nEnter the location of Head : "; cin>>h; cout<<"\nEnter 3 Requests to proceed : "; for(i=0;i<=7;i++) { cout<<"\nEnter ["<<i<<"]request : "; cin>>a[i]; } for(i=0;i<8;i++) { b[i]=abs(h-a[i]); } min=b[0]; p=0; for(i=0;i<8;i++){ if(min>b[j]) { min=b[j]; p=j; } s+=abs(h-a[p]); h=a[p]; } cout<<s; }

3rd Nov 2018, 7:05 PM
M W
M W - avatar
1 Answer