#include <stdio.h>
#include <iostream>
#include<stack>
#include<queue>
#include<cmath>
#include<stdlib.h>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
/*
请设计程序,用于模拟页式存储管理中,逻辑地址到物理地址的转换。
要求:能根据用户输入的页面大小、页表、和逻辑地址,
输出该逻辑地址所在页号、页内位移和物理地址。
*/
int main(){
int PageSize;
int PageLong;
int PageTable[10];
int PhysicalAddress;
cout<<"页面大小(kb):"<<endl;
cin>>PageSize;
cout<<"页表长度(max:10):"<<endl;
cin>>PageLong;
for(int i=0;i<PageLong;i++)
{
cout<<i<<"所对应的物理块"<<endl;
cin>>PageTable[i];
}
cout<<"物理地址:"<<endl;
cin>>PhysicalAddress;
cout<<"页号:"<<PhysicalAddress/1024-1<<endl;
cout<<"页内位移:"<<PhysicalAddress%1024<<endl;
cout<<"物理地址:"<<PageTable[(PhysicalAddress/1024)-1]*PageSize*1024+PhysicalAddress%1024<<endl;
}
/*
*/
【水汐のC++】请设计程序,用于模拟页式存储管理中,逻辑地址到物理地址的转换。 要求:能根据用户输入的页面大小、页表、和逻辑地址, 输出该逻辑地址所在页号、页内位移和物理地址。
最新推荐文章于 2023-12-13 13:38:55 发布