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; }
1 Réponse