public static void output(int[] pageAddresses) { for(int i = 4; i <= 40; i ++) { calculteOPT(pageAddresses, i); calculteFIFO(pageAddresses, i); calculteLRU(pageAddresses, i); } System.out.println("页框数\tOPT命中率\tFIFO命中率\tLRU命中率"); for(int i = 0; i < 37; i ++) { System.out.printf("[%d]\t",i+4); System.out.printf("OPT:%.4f",accuracy[0][i]); System.out.printf("\tFIFO:%.4f",accuracy[1][i]); System.out.printf("\tLRU:%.4f\n",accuracy[2][i]); } }写出这段代码的伪代码
时间: 2024-04-01 13:38:24 浏览: 20
1. 对于页框数从 4 到 40,分别调用 calculteOPT、calculteFIFO 和 calculteLRU 函数,计算三个页面替换算法在该页框数下的命中率。
2. 打印表头 "页框数 OPT命中率 FIFO命中率 LRU命中率"。
3. 对于每个页框数,打印该页框数下三个页面替换算法的命中率,格式为:"[页框数] OPT:命中率 FIFO:命中率 LRU:命中率"。
相关问题
{ public static void main(String[] args) { int i=8, j=2; while(j< --i) for(int k=0; k<4; k++) j++; System.out.print(j); } }
As an AI language model, I cannot run the code or access the actual output. However, I can explain what the code does.
The code initializes two integer variables, i and j, with the values 8 and 2 respectively.
Then it enters a while loop that continues until j is less than the pre-decremented value of i.
Inside the while loop, there is a for loop that runs 4 times, incrementing k by 1 each time. However, the loop body is empty, so nothing happens in the for loop.
After the for loop, j is incremented by 1. This process repeats until j is no longer less than the pre-decremented value of i.
Finally, the code prints the value of j.
Based on the code, the output should be 4.
public class Test< public static String output = "'; public static void foo(int i)‹ try { iffi = 1){ throw new Exception; output += "1", •catch(Exception e){ output += "2". return; }finally output += "3"; output += "4"; public static void main(String args) { foo (0); foo(1); System.out. printIn("output = "+output); ~ 3,找出下列程宇类中错误的
语法:
public class Test< {
public static String output = "';
public static void foo(int i)‹
try {
if(i == 1){
throw new Exception;
}
output = "1";
} catch(Exception e){
output = "2";
return;
} finally {
output = "3";
}
output = "4";
}
public static void main(String args) {
foo (0);
foo(1);
System.out. printIn("output = " + output);
}
}
错误的语法包括:
1. public class Test< 中的 "<" 应该是 "<T>",表示泛型类。
2. 第一行的 output 变量应该是 "String" 类型,而不是 "';"。
3. foo 方法中的 try 块中,throw new Exception 后面应该加上括号,即 throw new Exception()。
4. if(i == 1) 中的 "==" 应该是 "=".
5. System.out. printIn 应该是 System.out.println,println 后面应该加上括号。