Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
542 B
1
Indexable
Never
#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);
}
print("seek is %d\n",seek);
avg=seek/n;
printf("average is %f",avg);
}


Leave a Comment