Untitled
unknown
plain_text
a year ago
546 B
5
Indexable
#include<stdio.h> void main() { int i,r[100],diff,seek=0,head,max,n; float avg; printf("enter the max"); scanf("%d",&max); printf("enter the length of the string"); scanf("%d",&n); printf("enter the reference string"); for(i=0;i<n;i++) scanf("%d",&r[i]); printf("enter the current head position\n"); scanf("%d",&head); r[0]=head; for(i=0;i<=n-1;i++) { diff=abs(r[i+1]-r[i]); seek+=diff; printf("the head position moves from %d to %d with seek%d\n",r[i],r[i+1],seek); } printf("seek is %d\n",seek); avg=seek/n; printf("average is %f",avg); }
Editor is loading...
Leave a Comment