增补博客 第十七篇 python 模拟页面调度LRU算法
1.增补博客 第二篇 python 谢宾斯基三角型字符分形图形输出2.增补博客 第三篇 python 英文统计3.增补博客 第四篇 python 中文级联菜单4.增补博客 第五篇 python 电子算盘5.增补博客 第六篇 python 电子算盘6.增补博客 第七篇 python 比较不同Python图形处理库或图像处理库的异同点7.增补博客 第八篇 python 中国大学排名数据分析与可视化8.增补博客 第九篇 python 图书评论数据分析与可视化9.增补博客 第十篇 python 函数图形绘制10.增补博客 第十一篇 python 分段函数图形绘制11.增补博客 第十二篇 python大作业小说阅读器(1)爬取12.增补博客 第十三篇 python大作业小说阅读器(2)爬取13.增补博客 第十四篇 python大作业小说阅读器(3)显示文字函数14.增补博客 第十五篇 python大作业小说阅读器(4)html页面
15.增补博客 第十七篇 python 模拟页面调度LRU算法
16.增补博客 第十八篇 python 杨辉三角形17.增补博客 第二十篇 python 筛法求素数18.增补博客 第二十一篇 python 查找鞍点19.增补博客 第二十四篇 python 正整数的因子展开式20.增补博客 第二十二篇 python 牛顿迭代法21.增补博客 第二十三篇 python 对比Python中的列表、元组、字典、集合、字符串等之间异同22.增补博客 第十九篇 python 爬楼梯23.增补博客 第一篇 python 简易带参计算器24.增补博客 第十六篇 python 排列组合序列25.增补博客 第二十五篇 python 列举说明Python同Java及C++的不同之处1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | 【题目描述】所谓LRU算法,是指在发生缺页并且没有空闲主存块时,把最近最少使用的页面换出主存块,腾出地方来调入新页面。<br>问题描述:一进程获得n个主存块的使用权,对于给定的进程访问页面次序,问当采用LRU算法时,输出发生的缺页次数。<br>【练习要求】请给出源代码程序和运行测试结果,源代码程序要求添加必要的注释。<br>【输入格式】在第一行中输入进程获得使用权的主存块数量n。<br>在第二行中输入进程访问页面的次序,各数据之间以空格为间隔。<br>【输出格式】输出对于给定的n和进程访问页面的次序,输出采用LRU算法时的缺页次数。<br>【输入样例】 3 <br> 1 2 3 4 1 2 5 1 2 3 4 5 <br>【输出样例】 7 <br><br> import math<br> # 三维图形功能接口 class ThreeDimensionalShape: def perimeter( self ): pass def area( self ): pass def volume( self ): pass # 定义点类 class Point: def __init__( self , x, y): self .x = x self .y = y def get_coordinates( self ): return self .x, self .y def set_coordinates( self , x, y): self .x = x self .y = y def display( self ): print ( "点坐标: ({}, {})" . format ( self .x, self .y)) # 圆类 class Circle(Point): def __init__( self , x, y, radius): super ().__init__(x, y) self .radius = radius def get_radius( self ): return self .radius def set_radius( self , radius): self .radius = radius def perimeter( self ): return 2 * math.pi * self .radius def area( self ): return math.pi * self .radius * * 2 def display( self ): super ().display() print ( "半径: " , self .radius) print ( "周长: " , self .perimeter()) print ( "面积: " , self .area()) # 球类 class Sphere(Circle, ThreeDimensionalShape): def __init__( self , x, y, radius): super ().__init__(x, y, radius) def volume( self ): return ( 4 / 3 ) * math.pi * self .radius * * 3 def display( self ): super ().display() print ( "体积: " , self .volume()) # 圆柱类 class Cylinder(Circle, ThreeDimensionalShape): def __init__( self , x, y, radius, height): super ().__init__(x, y, radius) self .height = height def volume( self ): return math.pi * self .radius * * 2 * self .height def display( self ): super ().display() print ( "高度: " , self .height) print ( "体积: " , self .volume()) # 圆锥类 class Cone(Circle, ThreeDimensionalShape): def __init__( self , x, y, radius, height): super ().__init__(x, y, radius) self .height = height def volume( self ): return ( 1 / 3 ) * math.pi * self .radius * * 2 * self .height def display( self ): super ().display() print ( "高度: " , self .height) print ( "体积: " , self .volume()) # 测试 point = Point( 0 , 0 ) circle = Circle( 1 , 2 , 5 ) sphere = Sphere( 3 , 4 , 6 ) cylinder = Cylinder( 5 , 6 , 3 , 8 ) cone = Cone( 7 , 8 , 4 , 10 ) print ( "点:" ) point.display() print ( "-----------------" ) print ( "圆:" ) circle.display() print ( "-----------------" ) print ( "球:" ) sphere.display() print ( "-----------------" ) print ( "圆柱:" ) cylinder.display() print ( "-----------------" ) print ( "圆锥:" ) cone.display() |
合集:
python
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix