当前位置: 首页 > news >正文

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

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

教材学习内容总结

  • 数组元素:具有N个值的数组索引为0~(N-1)
  • 声明和使用数组: int[] height = new int[length]
  • 对象数组:将对象作为元素如例8.5中Grade的对象数组grades,例8.8中DVD对象数组collection
  • 命令行实参:调用解释器执行程序时命令行所包含的数据
  • 可变长度参数表:通过使用某种特殊语法的形参数,使所定义的方法能接收任意个数的参数,并将参数自动存入数组以便在方法中进行处理
  • 二维数组与多维数组:二维数组可表示为一个索引值为行,另一个为列,三维数组可表示为长方体,以此类推,但四维以上很难用图形表示

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

  • 问题1:对于例题8.3中upper[current-'A']++;不理解
  • 问题1解决方案:了解到这句话的意思是对每个字母参数的出现个数进行统计,即出现一次增加1
  • 问题2:对于二维数组的使用方法不清楚
  • 问题2解决方案:我在网上搜索到一篇比较详细介绍二维数组的方法,看了之后清楚多了 ,基本上的使用方法里面都涉及了

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

  • 问题1:编写PP8.1的时候最后结果没有出现50这个数
  • 问题1解决方案:原来的代码为final int NMCHAS = 50;,后来改成final int NUMCHAS = 51;,0到50有51个数,刚开始没怎么注意
  • 问题2:原先我写8.5的时候,对于计算其中的函数我应用了设置一个方法运用了可变长度参数表来计算平均数和方差,但编译时出现了错误

    private static double mean(int ... list)
    {
    double result =0.0;
    if (list.length !=0)
    {
    int sum = 0;
    for (int num : list)
    sum += num;
    result = (double)sum/list.length;
    }
    return result;
    }
    private static double sd(int ... list)
    {
    double result=0.0;
    if (list.length !=0)
    {
    double sum = 0.0;
    for (int num :list)
    sum += (num-mean(list))(nummean(list));
    result=Math.sqrt(sum);
    }
    return result;
    }
    _

  • 问题2解决方案:将两个方法放在public class pp8_5{} 内,而不是放在main方法内
  • 问题3 还是上面的代码,由于之前没在同一个类中用main方法和定义其他方法,出现了无法从静态上下文中引用非静态方法 的错误
  • 问题3解决方案:将两个方法都设置成static静态方法

代码托管

1333059-20180415225028981-577368460.png

上周考试错题总结

  • 错题1及原因,理解情况
    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,if语句程序执行是从左到右的,if左边错误,不会判断右边,避免了除零出现错误,if判断为假,不会执行if里面的语句,因此不会出现计算max的第二个除零错误
  • 错题2及原因,理解情况
    The break statement does which of the following?
    A . ends the program
    B . transfers control out of the current control structure such as a loop or switch statement
    C . ends the current line of output, returning the cursor
    D . denotes the ending of a switch statement
    E . indicates the end of line when using System.out.print
    选B,之前我选了C后来发现C是说返回游标,英语翻译方面还得加强理解

  • 错题3及原因,理解情况
    If a switch statement is written that contains no break statements whatsoever,
    A . this is a syntax error and an appropriate error message will be generated
    B . each of the case clauses will be executed every time the switch statement is encountered
    C . this is equivalent to having the switch statement always take the default clause, if one is present
    D . this is not an error, but nothing within the switch statement ever will be executed
    E . none of the above
    选E,没有break会自动跳转到之后的case语句,所以这样写没什么问题
  • 错题4及原因,理解情况
    Given the following code, where x = 0, what is the resulting value of x after the for-loop terminates?
    for (int i=0;i<5;i++)
    x += i;
    A . 0
    B . 4
    C . 5
    D . 10
    E . 15
    选D,循环之后x=1+2+3+4=10
  • 错题5及原因,理解情况
    Given that s is a String, what does the following loop do?
    for (int j = s.length( ); j > 0; j--)
    System.out.print(s.charAt(j-1));
    A . it prints s out backwards
    B . it prints s out forwards
    C . it prints s out backwards after skipping the last character
    D . it prints s out backwards but does not print the 0th character
    E . it yields a run-time error because there is no character at s.charAt(j-1) for j = 0
    选A,结合这周的数组就很好理解了,从最后一个字符向前输出出来的结果和原来的字符串相反
  • 错题6及原因,理解情况
    Which of the following statements are true about Java loops?
    A . all three loop statements are functionally equivalent
    B . while loops and do loops are essentially the same; but while loops always execute at least once
    C . if you know the number of times that a loop is to be performed, the best loop statement to use is a while loop
    D . loops may be replaced by an appropriate combination of if-else and switch statements
    E . none of the above
    选A,三个循环理论上来说是等价的
  • 错题7及原因,理解情况
    Each case in a switch statement must terminate with a break statement.
    A . true
    B . false
    选B,break语句不存在的情况下会跳过这个case继续执行下一个
  • 错题8及原因,理解情况
    The following for-loop is an infinite loop.
    for (int j = 0; j < 1000; ) i++;
    A . true
    B . false
    选A,i的增加对j的大小不会有影响,这是个无限循环
  • 错题9及原因,理解情况
    The following loop is syntactically valid.
    for (int j = 0; j < 1000; j++) j--;
    A . true
    B . false
    选B,会不断重复增加减少的过程,循环不会终止

点评模板:

  • 博客中值得学习的或问题:
    • 博客:图片比较少,对问题反映不直观
    • 对8.5研究比较深刻
  • 代码中值得学习的或问题:
    • 代码比较简洁,使用了与大多同学不同的方法

点评过的同学博客和代码

  • 本周结对学习情况
    • 20172312
    • 结对学习内容
    • 对课本内容的总结

学习进度条

代码行数(新增/累积)博客量(新增/累积)学习时间(新增/累积)重要成长
目标5000行30篇400小时
第一周128/1281/112/12
第二周212/3401/218/30
第三周206/5461/320/50
第四周483/10292/540/90
第五周633/16621/630/120
第六周560/22221/720/140

参考资料

  • 《Java程序设计与数据结构教程(第二版)》

  • 《Java程序设计与数据结构教程(第二版)》学习指导

转载于:https://www.cnblogs.com/m1sty/p/8848809.html

相关文章:

  • 坚持不走寻常路 解读“锐捷式”创新的三个突破
  • Java基础-正则表达式(Regular Expression)语法规则简介
  • 你不知道的js坑
  • 关于肥胖和美国为什么那么多胖子
  • 机器视觉技术太阳能光伏硅片EL检测方案
  • BTA | 王涛:传统IT人如何用数据库思维来理解区块链?去中心化数据库也许是答案...
  • Vivint大规模IoT部署的指标收集
  • [NOSQL] Redis介绍
  • JS 面试题总结
  • (翻译)Quartz官方教程——第一课:Quartz入门
  • c++(类) this指针
  • 【Python改变生活!】用pynput控制键盘鼠标!Mac如何卸载python?
  • Docker 镜像、容器、仓库的概念及基本操作
  • 十分钟讲清楚大众对区块链的误解
  • 移动端适配问题解决方案
  • 【面试系列】之二:关于js原型
  • Date型的使用
  • gitlab-ci配置详解(一)
  • MYSQL如何对数据进行自动化升级--以如果某数据表存在并且某字段不存在时则执行更新操作为例...
  • Webpack4 学习笔记 - 01:webpack的安装和简单配置
  • 初识 webpack
  • 类orAPI - 收藏集 - 掘金
  • 前端之Sass/Scss实战笔记
  • 适配mpvue平台的的微信小程序日历组件mpvue-calendar
  • 手机app有了短信验证码还有没必要有图片验证码?
  • 在 Chrome DevTools 中调试 JavaScript 入门
  • media数据库操作,可以进行增删改查,实现回收站,隐私照片功能 SharedPreferences存储地址:
  • CMake 入门1/5:基于阿里云 ECS搭建体验环境
  • 机器人开始自主学习,是人类福祉,还是定时炸弹? ...
  • #HarmonyOS:Web组件的使用
  • %check_box% in rails :coditions={:has_many , :through}
  • (javascript)再说document.body.scrollTop的使用问题
  • (LNMP) How To Install Linux, nginx, MySQL, PHP
  • (亲测有效)解决windows11无法使用1500000波特率的问题
  • (未解决)macOS matplotlib 中文是方框
  • (续)使用Django搭建一个完整的项目(Centos7+Nginx)
  • (已解决)vue+element-ui实现个人中心,仿照原神
  • (转载)微软数据挖掘算法:Microsoft 时序算法(5)
  • *ST京蓝入股力合节能 着力绿色智慧城市服务
  • .NET/C# 编译期间能确定的相同字符串,在运行期间是相同的实例
  • .net反混淆脱壳工具de4dot的使用
  • .NET面试题解析(11)-SQL语言基础及数据库基本原理
  • .net中应用SQL缓存(实例使用)
  • .stream().map与.stream().flatMap的使用
  • :“Failed to access IIS metabase”解决方法
  • [ 第一章] JavaScript 简史
  • [AIGC] SQL中的数据添加和操作:数据类型介绍
  • [CF226E]Noble Knight's Path
  • [CISCN2019 华东南赛区]Web11
  • [FTP]pureftp部署和优化
  • [HackMyVM]靶场 Wild
  • [IE9] IE9 beta版下载链接
  • [Json.net]快速入门
  • [JS入门到进阶] 前端开发不能写undefined?这是误区!
  • [MTK]安卓8 ADB执行ota升级