码迷,mamicode.com
首页 > 其他好文 > 详细

20172307 2017-2018-2 《程序设计与数据结构》第6周学习总结

时间:2018-04-15 22:58:50      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:alt   条件语句   tab   可变   img   written   other   ISE   .com   

学号 2017-2018-2 《程序设计与数据结构》第6周学习总结

教材学习内容总结

本章学习了第八章的内容
1.讲了创建声明数组的方法(示例: int[] height = new int[11];)和创建基本数据一样要声明数据的类型。
2.边界检查中的差一错误属于逻辑错误,主要是因为索引值是从0开始的。
3.数组本身就是对象
4.可变长度参数表声明创建方式(示例:public double average(int .. list))省略号表示该方法接收的参数个数是可变的。
5.二维数组的声明创建方式(示例:int[][] table = new int[5][10])前一个表示数组的长度也是行数,后一个表示前一个表示的行里的列数。

教材学习中的问题和解决过程

  • 问题1:对什么是数组并不太清楚。
  • 问题1解决方案:通过网上的一些解释和对书本定义的重新理解得到了以下定义:数组是保存一列数据的对象。整列数据可以通过数组名引用,数组中的每个元素则可以通过其在数组中的位置进行引用。
  • 问题2:对书上的“差一错误”理解不进去
  • 问题2解决方案:通过查阅网上的解释明白了差一错误属于逻辑错误,由于索引值从0开始导致。

代码调试中的问题和解决过程

  • 在进行 x +=y[];时发生错误
    数组也是对象,把x变成同一类型的对象就能进行相加。

代码托管

技术分享图片

上周考试错题总结

  • The idea that program instructions execute in order (linearly) unless otherwise specified through a conditional statement is known as
    A . boolean execution
    B . conditional statements
    C . try and catch
    D . sequentiality
    E . flow of control
    正确:E
    程序按照条件语句顺序执行叫做控制流。
  • Assume that count is 0, total is 20 and max is 1. The following statement will do which of the following? if (count != 0 && total / count > max) max = total / count;
    A . The condition short circuits and the assignment statement is not executed
    B . The condition short circuits and the assignment statement is executed without problem
    C . The condition does not short circuit causing a division by zero error
    D . The condition short circuits so that there is no division by zero error when evaluating the condition, but the assignment statement causes a division by zero error
    E . The condition will not compile because it uses improper syntax
    正确:A
    由于count=0不符合if的循环条件,所以语句不会执行。
  • If a break occurs within the innermost loop of a nested loop that is three levels deep
    A . when the break is encountered just the innermost loop is "broken"
    B . when the break is encountered, all loops are "broken" and execution continues from after the while statement (in our example)
    C . when the break is encountered, all but the outermost loops are broken, and execution continues from the next iteration of the while loop (in our example)
    D . this is a syntax error unless there are break or continue statements at each loop level
    E . none of the above
    正确:A
    break只会跳出当前的循环。也就是最里面的循环。
  • In order to compare int, float and double variables, you can use <, >, ==, !=, <=, >=, but to compare char and String variables, you must use compareTo( ), equals( ) and equalsIgnoreCase( ).
    A . true
    B . false
    正确:B
    字符和字符串也可以用其他来比较,如==来比较,这时比较的是他们的地址是否一致。
  • The statement if (x < 0) y = x; else y = 0; can be rewritten using a conditional operator as
    A . y = (x < 0) ? x : 0;
    B . x = (x < 0) ? y : 0;
    C . (x < 0) ? y = x : y = 0;
    D . y = (x < 0);
    E . y = if (x < 0) x : 0;
    正确:A
    对条件运算符的应用。
  • Each case in a switch statement must terminate with a break statement.
    A . true
    B . false
    正确:B
    偶尔也有需要依次执行所有case语句的情况。

学习进度条

代码行数(新增/累积) 博客量(新增/累积) 学习时间(新增/累积) 重要成长
目标 5000行 30篇 400小时
第一周 200/200 2/2 20/20
第二周 300/500 1/3 18/38
第三周 500/1000 1/4 22/60
第四周 300/1300 1/5 30/90
第五周 700/ 2000 1/6 30/120
第六周 792/2792 1/7 30/150

参考资料

20172307 2017-2018-2 《程序设计与数据结构》第6周学习总结

标签:alt   条件语句   tab   可变   img   written   other   ISE   .com   

原文地址:https://www.cnblogs.com/20172307hyt/p/8848207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!