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. 太阳天或下雨天 One Night In Shanghai

    回来了上海。 在k歌的时候,朋友msg来说在周末抽空去老北京逛了一夜,夜里msn上叫One Night In […]...

  2. mkdir -p 参数的使用

    ssh root@%s -o ConnectTimeout=2 “ssh root@%s Conn […]...

  3. 珍藏多年的学习资料300G+,赶紧免费领取,从此离大神更进一步

    将时间线拉到2014     2014年的寒冬,每天早晨六点钟,都会一个弱小的身影,从学校寝室出发,走在去实习 […]...

  4. Numerical methods in enginering with python3 (1)

    <> (1) Numpy 库 Numpy中的矩阵函数 np.diagonal(A) 返回由A中的主 […]...

  5. Name Disambiguation in AMiner-Clustering, Maintenance, and Human in the Loop

    Name Disambiguation in AMiner: Clustering, Maintenance, […]...

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

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

  7. .Net Core in Docker – 使用阿里云Codepipeline及阿里云容器镜像服务实现持续交付/部署(CD)

    上一次演示了如何使用阿里云Codepipeline,阿里云容器镜像服务实现CI,讲到这里我们push一下代码后 […]...

  8. 【AI in 美团】深度学习在OCR中的应用 – 美团技术团队

    【AI in 美团】深度学习在OCR中的应用 计算机视觉是利用摄像机和电脑代替人眼,使得计算机拥有类似于人类的 […]...

随机推荐

  1. MYSQL数据库设计和数据库设计实例(三)

      数据库设计—-概念结构设计   1>将需求分析得到的用户需求抽象为信息结构,这个信息结构 […]...

  2. linux中 替换内容的命令

    1、vi命令下的查找和替换 1.1 vi下的查找 /hello<Enter> :向下查找hello […]...

  3. Github不为人知的一个功能,一个小彩蛋

    在Github上,创建自己的readme.md文件,官方的一个小彩蛋。 Github 是一个基于Git的代码托 […]...

  4. Django+vue在腾讯云上搭建前后端分离项目

    最近打算用Django+vue搭建一个个人主站,在此记录一下搭建项目的整个过程。 一 开发环境:   腾讯云C […]...

  5. 消息中间件企业级应用

    消息中间件企业级应用 众所周知,消息中间件是大型分布式系统中不可或缺的重要组件。它使用简单,却解决了不少难题, […]...

  6. 【5min+】 巨大的争议?C# 8 中的接口

    系列介绍 【五分钟的dotnet】是一个利用您的碎片化时间来学习和丰富.net知识的博文系列。它所包含了.ne […]...

  7. 看过的书籍(转)

    1.C++程序设计 (钱能)这本书适合用于入门书或者课堂教程,了解一下C++语法特点,有啥关键字等。 2.Wi […]...

  8. android recovery模式及ROM制作

    转自android recovery模式及ROM制作 1.总述 为了方便客户日后的固件升级,本周研究了一下an […]...

展开目录

目录导航