Programming abstractions in C阅读笔记: p114-p117
《Programming Abstractions in C》学习第48天,p114-p117,总结如下:
一、技术总结
主要通过random number介绍了随机数的相关用法,interface示例(random.h),client program示例(craps.c)。
#include <stdio.h>
#include "genlib.h"
#include "random.h"
static bool TryToMakePoint(int point);
static int RollTwoDice(void);
void main() {
int point;
Randomize(); // 定义在自定义的random.h文件中
printf("This program plays a game of craps.\n");
point = RollTwoDice();
switch (point) {
case 7: case 11:
printf("That's a natural. You win.\n");
break;
case 2: case 3: case 12:
printf("That's craps. You lose.\n");
break;
default:
printf("Your point is %d.\n", point);
if (TryToMakePoint(point)) {
printf("You made your point. You win.\n");
} else {
printf("You rolled a seven. You lose.\n");
}
}
}
static bool TryToMakePoint(int point) {
int total;
while (TRUE) {
total = RollTwoDice();
if (total == point) return TRUE;
if (total == 7) return FALSE;
}
}
static int RollTwoDice(void) {
int d1, d2, total;
printf("Rolling the dice ...\n");
d1 = RandomInteger(1, 6); // 定义在自定义的random.h文件中
d2 = RandomInteger(1, 6);
total = d1 + d2;
printf("You rolled %d and %d -- that's %d.\n", d1, d2, total);
return total;
}
二、英语总结
1.inclusive什么意思?
答:adj. including a particular thing。当讨论涉及到范围时,我们经常会说在某两个数之间,如果包含这两个数,那么就用inclusive这个词来形容这两个数。示例:p114,The first prototype is for the function RandomInteger(low, high), which return a randomly chosen integer in the range between low and high, inclusive。
2.subject to sth语法
答:subject用法最常见的是用作noun,不过subject也可以用作adjective。subject to sth:only able to happen if sth else happen。
三、数学总结
1.区间相关概念
(1) 半开区间: half-open internal
(2) open circle:open circle
(3) 方括号:square bracket
三、参考资料
1.编程
(1)Eric S.Roberts,《Programming Abstractions in C》:https://book.douban.com/subject/2003414
2.英语
(1)Etymology Dictionary:https://www.etymonline.com
(2)Cambridage Dictionary:https://dictionary.cambridge.org
欢迎搜索及关注:编程人(a_codists)
Programming abstractions in C阅读笔记: p114-p117的更多相关文章
- Mongodb Manual阅读笔记:CH3 数据模型(Data Models)
3数据模型(Data Models) Mongodb Manual阅读笔记:CH2 Mongodb CRUD 操作Mongodb Manual阅读笔记:CH3 数据模型(Data Models)Mon ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十三章:角色动画
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二十三章:角色动画 学习目标 熟悉蒙皮动画的术语: 学习网格层级变换 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十一章:模板测试
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第十一章:模板测试 代码工程地址: https://github.co ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第六章:在Direct3D中绘制 代码工程地址: https://gi ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第四章:Direct 3D初始化
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第四章:Direct 3D初始化 学习目标 对Direct 3D编程在 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二章:矩阵代数
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第二章:矩阵代数 学习目标: 理解矩阵和与它相关的运算: 理解矩阵的乘 ...
- Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数
原文:Introduction to 3D Game Programming with DirectX 12 学习笔记之 --- 第一章:向量代数 学习目标: 学习如何使用几何学和数字描述 Vecto ...
- 阅读笔记 1 火球 UML大战需求分析
伴随着七天国庆的结束,紧张的学习生活也开始了,首先声明,阅读笔记随着我不断地阅读进度会慢慢更新,而不是一次性的写完,所以会重复的编辑.对于我选的这本 <火球 UML大战需求分析>,首先 ...
- [阅读笔记]Software optimization resources
http://www.agner.org/optimize/#manuals 阅读笔记Optimizing software in C++ 7. The efficiency of differe ...
- 《uml大战需求分析》阅读笔记05
<uml大战需求分析>阅读笔记05 这次我主要阅读了这本书的第九十章,通过看这章的知识了解了不少的知识开发某系统的重要前提是:这个系统有谁在用?这些人通过这个系统能做什么事? 一般搞清楚这 ...
随机推荐
- 2020-10-22:谈谈java中的LongAdder和LongAccumulator的相同点和不同点。
福哥答案2020-10-22: 简单回答:相同点:都是多个单元操作.不同点:LongAdder相加,LongAccumulator自定义计算规则. 中级回答:相同点: LongAddr与LongAcc ...
- SICP:惰性求值、流和尾递归(Python实现)
求值器完整实现代码我已经上传到了GitHub仓库:TinySCM,感兴趣的童鞋可以前往查看.这里顺便强烈推荐UC Berkeley的同名课程CS 61A. 即使在变化中,它也丝毫未变. --赫拉克利特 ...
- 如何在前端应用中合并多个 Excel 工作簿
本文由葡萄城技术团队于博客园原创并首发.葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 前言|问题背景 SpreadJS是纯前端的电子表格控件,可以轻松加载 Excel 工作簿中的数据 ...
- SpringBoot定义优雅全局统一Restful API 响应框架五
闲话不多说,继续优化 全局统一Restful API 响应框架 做到项目通用 接口可扩展. 如果没有看前面几篇文章请先看前面几篇 SpringBoot定义优雅全局统一Restful API 响应框架 ...
- vulnhub_jangow
来源 vulnhub:https://www.vulnhub.com/entry/jangow-101,754/ 描述 难度:简单 这在 VirtualBox 而不是 VMware 上效果更好 我这里 ...
- 使用CNI网络插件(calico)实现docker容器跨主机互联
目录 一.系统环境 二.前言 三.CNI网络插件简介 四.常见的几种CNI网络插件对比 五.Calico网络之间是如何通信的 六.配置calico让物理机A上的docker容器c1可以访问物理机B上的 ...
- 搭建springbootweb环境
搭建springboot环境(idea环境) 实现步骤: 1.基础环境配置 2.maven配置 3.编写第一个程序helloworld(可能有两个小问题) 4.运行(jar包运行,命令行运行) 一.基 ...
- Supervisor启动并管理Celery相关进程
Supervisor启动并管理Celery相关进程 关于celery在运行过程中, 默认情况下是无法在关机以后自动重启的.所以我们一般开发中会使用supervisor进程监控来对celery程序进行运 ...
- 洛谷 P5979 [PA2014] Druzyny
简要题意 有 \(n\) 个人,把他们划分成尽可能多的区间,其中第 \(i\) 个人要求它所在的区间长度大于等于 \(c_i\),小于等于 \(d_i\),求最多的区间数量以及如此划分的方案数. 数据 ...
- 前端vue uni-app列表组件 list组件,简单好用
快速实现uni-app列表组件 list组件,简单好用; 下载完整代码请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=12675 效果图如下: ...