Some notes in Stanford CS106A

wleaves 2019-03-07 原文

Some notes in Stanford CS106A

Karel world

1.During make a divider operation

–int x=5; double y = x/2  =>  y=2

we need sth as a double for the purpose of this operation treat it as though it were a double .

–int x=5; double y = (double)x/2  =>  y=2.5

OR

–int x=5; double y = x/2.0  =>  y=2.5

2.Define a const that can’t be changed

private static final doule PI=3.14;

final:the value won’t change after I give its initial value,

static:there’s only one of these for the entire class,

private: it only lives inisde the class.

3.A buggy in boolean 

boolean p = (x !=1) || (x!=2) 

=>correct is : boolean p = (x !=1) && (x!=2) 

4.Scope: lifetime of variable 

5.While cast sth that lose information , like from double to a integer , you have to put in the CAST.

ex. double y = 3.5; int x = (int) y;

(if doesn’t lose information like int to double , you dont have to cast.)

6.For versus while

For loop used for definite iteration(Generally we know how many times we want to iterate)

While loop used for indefinate iteration(Generally don’t know how many times to iterate beforehand.)

 

发表于 2019-03-07 18:12 苏悠莫 阅读() 评论() 编辑 收藏

 

版权声明:本文为wleaves原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/wleaves/p/10491367.html

Some notes in Stanford CS106A的更多相关文章

  1. SQL IN 一定走索引吗?

    摘要 IN 一定走索引吗?那当然了,不走索引还能全部扫描吗?好像之前有看到过什么Exist,IN走不走索引的讨 […]...

  2. In machine learning, is more data always better than better algorithms?

    In machine learning, is more data always better than be […]...

  3. for for in 给已有的li绑定click事件生成新的li也有click事件

    想要给已有的li元素绑定一个click事件,点击生成新的li元素,并且新的li元素也要有click事件   / […]...

  4. 深度学习论文翻译解析(三):Detecting Text in Natural Image with Connectionist Text Proposal Network

    论文标题:Detecting Text in Natural Image with Connectionist […]...

  5. 程序猿学英语—In July the English learning summary

        七月的英语学习更加曲折,七月初。查看更多,周六和周日可以保证每天两小时的英语教室学习。周一到周 五一般 […]...

  6. MySQL模糊匹配查询like、regexp、in

      MySQL提供标准的SQL模式匹配,以及一种基于像Unix实用程序,如:vi、grep和sed的扩展正则表 […]...

  7. error: failed to commit transaction (conflicting files) curl: /usr/bin/curl exists in filesystem

    error: failed to commit transaction (conflicting files) […]...

  8. 【RS】Modeling User Exposure in Recommendation – 在推荐中建模用户的暴露程度 – CuriousZero

    【RS】Modeling User Exposure in Recommendation – 在推 […]...

随机推荐

  1. 功能测试报告模版

                芯盾时代xxx系统 x.x.x版本 功能测试报告                   […]...

  2. 给赛车游戏手柄接上仪表盘

    给赛车游戏手柄接上仪表盘 我也很迷赛车游戏,尽管在现实生活中我不会开车,但我仍然可以体会到那种酣畅淋漓的快感。 […]...

  3. 领域驱动最佳实践–用代码来告诉你来如何进行领域驱动设计

    做一个租户系统下的权限服务,接管用户的认证和授权,我们取名该服务为go-easy-login      本文实 […]...

  4. Docker 系列四(自定义仓库).

    一、Docker hub 交互     Docker hub 是 Docker 官方维护的一个公共仓库,大部分 […]...

  5. QQ是怎样创造出来的?——解密好友系统的设计

    本篇介绍笔者接触的第一个后台系统,从自身见闻出发,因此涉及的内容相对比较基础,后台大牛请自觉略过。 什么是好友 […]...

  6. subplot 设置不一样的图片大小和位置 – Airboy1

    subplot 设置不一样的图片大小和位置 t=[0:0.1:25]; y1=exp(-t/3); y3=si […]...

  7. Vue开发之基础路由

    1.router-link和router-view组件 src/App.vie文件内容: <templa […]...

  8. 微信小程序实现下拉刷新

    本文将简单介绍如何实现微信小程序的下拉刷新 将要使用的api: wx.showNavigationBarLoa […]...

展开目录

目录导航