【水汐のC++】请设计程序,用于模拟页式存储管理中,逻辑地址到物理地址的转换。 要求:能根据用户输入的页面大小、页表、和逻辑地址, 输出该逻辑地址所在页号、页内位移和物理地址。

#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;
}
/*

*/

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值