You are on page 1of 2

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package os;
import java.util.Scanner;
/**
*
* @author student
*/
public class Main {
public static void main(String[] args) {
int n,i,j,k,m,n1;
int b[]=new int[50];
int c[]=new int[50];
Scanner sc=new Scanner(System.in);
System.out.println("enter the page frame");
n=sc.nextInt();
System.out.println("enter the num of pages to b entered");
n1=sc.nextInt();
System.out.println("pages to be entered are"+n1);
System.out.println("enter the pages:");
for(i=0;i<n1;i++)
{
b[i]=sc.nextInt();
}
k=0;m=0;i=0;
int g=0;
for(j=0;j<n1;j++)
{
if(m==n)
{
m=0;
}
if(j<n)
{
c[i]=b[j];
i++;
k++;
for(int l=0;l<i;l++)
{
System.out.print(c[l]);
System.out.print(" ");
}
System.out.println("");
}
else
{
for(i=0;i<n;i++)
{
if(b[j]==c[i])
{
g++;
}
}
if(g==0)
{
k++;
c[m]=b[j];
m++;
for(int l=0;l<n;l++)
{
System.out.print(c[l]);
System.out.print(" ");
}
System.out.println("");
g=0;
}
else
g=0;

}
}
System.out.println("page fault ="+k);

}}

You might also like