想要详细的每一步代码的解析与注释,和声明了几个变量有几个类,以及运行结果等。谢谢🙏
<!--操作按钮-->
<div class="cart_operating clearfix">
<div class="cart_operating_style">
<div class="cart_price">商品总价:(不含运费)<b>¥0.00</b></div>
<div class="cart_btn">
<a href="javascript:void(0);" class="payment_btn">
<div class="paymentAllowed">马上付款</div></a>
<a href="#" class="continue_btn"></a>
</div>
</div>
</div>
<!-- 浮现栏 -->
<div class="floatTitle" style="border: 1px gainsboro solid;height: 50px;line-height: 50px;display: none;width: 1000px;">
<div style="font-size: 17px;display:inline;float: left">
已选商品
<span style="color: red;" id="float_count">0</span> 件
</div>
<div class="cart_price" style="display:inline;font-size: 17px;float: left;padding-left: 150px;padding-right: 180px;">
商品总价:(不含运费)<b style="color: red">¥0.00</b>
</div>
<div class="cart_btn" style="display:inline; ">
<a href="javascript:void(0);" class="payment_btn">
<div class="paymentAllowed">马上付款</div>
</a>
<a href="#" class="continue_btn"></a>
</div>
</div>
<script type="text/javascript">
$(function() {
$(window).scroll(function () {//鼠标滑动事件
var height = $(".cart_btn").offset().top;//计算该框离浏览器顶部的距离
if (height >= $(window).scrollTop() && height < ($(window).scrollTop() + $(window).height())) {
$(".floatTitle").hide();
}else {
$(".floatTitle").show();
}
});
//跳转到购物车页面加载时候
var height = $(".cart_btn").offset().top;//计算该框离浏览器顶部的距离
if (height >= $(window).scrollTop() && height < ($(window).scrollTop() + $(window).height())) {
$(".floatTitle").hide();
}else {
$(".floatTitle").show();
}
});
</script>
答案:
段落0:
代码中声明的类:randomizedSelection
代码中声明的变量:A, result
代码注释和运行结果:
//初始化一个整型数组A, 代表我们需要寻找第五大的数值 int[] A = {9,8,7,6,5,4,3,2,1}; //下面中randomizedSelection(A, 0, A.length-1, 5)里的第四个参数,代表的是寻找该数组中排序后的第几个元素。所以,第四个参数的值不能超过数组的长度 int result = randomizedSelection(A, 0, A.length-1, 5); //输出结果为5 System.out.println(result);
运行结果:5
段落1:
代码中声明的类:main, CiDao, FIFO, SCAN, SSTF, CSCAN
代码中声明的变量:C, target, sum, fifo, scan, sstf, cscan
代码注释和运行结果:
//初始化CiDao类,设置初始化起始位置 CiDao C = new CiDao(); C.setFistNum(100); //初始化一个int数组,代表寻道队列 int[] target = {45, 23, 67, 2, 9, 89, 165, 49, 80, 77, 255, 184, 196, 145}; C.setTarget(target); int sum = 0; //初始化FIFO, SCAN, SSTF, CSCAN这四个类 FIFO fifo = new FIFO(); SCAN scan = new SCAN(); SSTF sstf = new SSTF(); CSCAN cscan = new CSCAN(); //以下是四个算法寻找磁道的过程,并输出总移动道数和平均寻道数 System.out.println("----FIFO----"); sum = fifo.Do(C.getTarget(), C.getFistNum()); System.out.println("磁头移动的总道数为:" + sum + " ;平均寻道数为:" + (1.0 * sum / target.length)); System.out.println("----SSTF----"); sum = sstf.Do(C.getTarget(), C.getFistNum()); System.out.println("磁头移动的总道数为:" + sum + " ;平均寻道数为:" + (1.0 * sum / target.length)); System.out.println("----SCAN----"); sum = scan.Do(C.getTarget(), C.getFistNum()); System.out.println("磁头移动的总道数为:" + sum + " ;平均寻道数为:" + (1.0 * sum / target.length)); System.out.println("----CSCAN----"); sum = cscan.Do(C.getTarget(), C.getFistNum()); System.out.println("磁头移动的总道数为:" + sum + " ;平均寻道数为:" + (1.0 * sum / target.length));
运行结果:
----FIFO---- 磁头移动的总道数为:597 ;平均寻道数为:42.642857142857146 ----SSTF---- 磁头移动的总道数为:291 ;平均寻道数为:20.785714285714285 ----SCAN---- 磁头移动的总道数为:335 ;平均寻道数为:23.92857142857143 ----CSCAN---- 磁头移动的总道数为:286 ;平均寻道数为:20.428571428571427
你先搞清楚概念吧
这个和类名相同的方法,没有返回值,这个叫做构造函数
然后这个 getxxx setxxx 叫做访问器(accessor)
这些代码虽然多,但是大部分都是差不多的,你先看看教材,概念搞清楚