{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

e7 - q h=q printf"\nTOTAL no of hits%d",q...

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++)       i=k;     }     z[i]=a[j];     i++;     disp(z,x);    }    else    {disp(z,x);     printf("\tHIT");
Background image of page 1

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

View Full Document Right 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: q++;} } h=q; printf("\nTOTAL no of hits %d",q); printf("\nHIT RATIO : %.2f",h/n); } void main() { int i,x,n,a[20]; clrscr(); printf("Enter the no of pages & index"); scanf("%d%d",&n,&x); printf("Enter the page nos"); for(i=0;i<n;i++) scanf("%d",&a[i]); lru(a,n,x); getch(); } Enter the no of pages & index12 3 Enter the page nos2 3 2 1 5 2 4 5 3 2 5 2 2 2 3 2 3 HIT 2 3 1 2 5 1 2 5 1 HIT 2 5 4 2 5 4 HIT 3 5 4 3 5 2 3 5 2 HIT 3 5 2 HIT TOTAL no of hits 5 HIT RATIO : 0.42...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

e7 - q h=q printf"\nTOTAL no of hits%d",q...

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

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