E7 - i=k; } z[i]=a[j]; i++; disp(z,x); } else {disp(z,x);

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> # /* RISHI AGARWAL LRU REPLACEMENT ALGO ROLL NO 02 SE CMPN A */ void disp(int z[],int x) { int i; printf("\n"); for(i=0;i<x;i++) if(z[i]!=-1) printf("%d ",z[i]); } void lru(int a[],int n,int x) { int i,j,z[5],q=0,l[2],k; float h; for(i=0;i<x;i++) z[i]=-1; i=0; for(j=0;j<n;j++) { { if(j>2) { l[0]=a[j-2]; l[1]=a[j-1]; for(k=0;k<x;k++)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i=k; } z[i]=a[j]; i++; disp(z,x); } else {disp(z,x); printf(&quot;\tHIT&quot;); q++;} } h=q; printf(&quot;\nTOTAL no of hits %d&quot;,q); printf(&quot;\nHIT RATIO : %.2f&quot;,h/n); } void main() { int i,x,n,a[20]; clrscr(); printf(&quot;Enter the no of pages &amp; index&quot;); scanf(&quot;%d%d&quot;,&amp;n,&amp;x); printf(&quot;Enter the page nos&quot;); for(i=0;i&lt;n;i++) scanf(&quot;%d&quot;,&amp;a[i]); lru(a,n,x); getch(); } /* / */...
View Full Document

Page1 / 2

E7 - i=k; } z[i]=a[j]; i++; disp(z,x); } else {disp(z,x);

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online