02 2022 档案
摘要:对象指针 指向一个对象 写法 p->sum() 和 (*p).sum() 是等价的,前者更加直观些 #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <algorithm> #in
阅读全文
摘要:CS61A python 字符串 str(1) = '1' 把数字等转化为字符串 + : 连接字符串 print(f"Debuting at #{place}: '{song}' by {artist}") artist = "Lil Nas X" song = "Industry Baby" pl
阅读全文
摘要:C++/oop 指针 按理说指针不是c++特有的东西,只是我恰好发现自己不太会,赶紧补一下 int *p 定义指针 p 指向 int 型变量 以下写法均可 int* p / int * p p = &a (& 取地址) 指针本身的类型是 unsigned long int *p 取内容 指针保存着变
阅读全文
摘要:面向对象 简单的说就是写很多类 每个类有自己的数据和函数,叫做“成员”。 类定义出来的变量,也称为类的实例,就是“对象”。 和struct 好像差不多 对象之间有 '=' 关系,其他的需要定义 private: 私有成员,只能在成员函数内访问public: 公有成员,可以在任何地方访问protect
阅读全文
摘要:c++/oop 引用 就相当于是原变量 int & a = b 相当于是别名 一个神奇的写法:引用作为函数返回值 1 int n = 4; 2 int & SetValue() { 3 return n; 4 } 5 int main() { 6 SetValue() = 40; 7 cout <<
阅读全文
摘要:CS61A pyhton 高阶函数 A function that either: Takes another function as an argument Returns a function as its result All other functions are considered fi
阅读全文
摘要:Boolean value : True / False and or not if 语句 if <condition>: <statement> <statement> if <condition>: <statement>elif <condition>: <statement>else : <
阅读全文
摘要:def <name>(<formal parameters>) : return <expression> eg def add(num1, num2): return num1 + num2 多行时缩进规则类似 haskell 调用函数的时候,函数会自己新建 local frame 在局部 loo
阅读全文
摘要:Arduino学习笔记 通信 双工 两条线,一收一发 单工 一条线,同时收发 半双工 一条线,分时双向通信 UART I^2C SP2
阅读全文
摘要:Arduino学习笔记 蜂鸣器 同样还是长正短负 float sinVal; int toneVal; void setup(){ pinMode(8, OUTPUT); } void loop(){ for(int x=0; x<180; x++){ //将sin函数角度转化为弧度 sinVal
阅读全文
摘要:Arduino学习笔记 Fade 呼吸灯 /* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. The analogWrite() function uses PWM, so
阅读全文
摘要:Arduino学习笔记 Blink without delay 上一篇里的 delay 非常拉,delay 的时候什么都不能做 这里把它规避掉 1 /* 2 Blink without Delay 3 4 Turns on and off a light emitting diode (LED) c
阅读全文
摘要:Arduino学习笔记 Blink Blink 应该是最简单的程序了 来自Arduino官网 1 /* 2 Blink 3 4 Turns an LED on for one second, then off for one second, repeatedly. 5 6 Most Arduinos
阅读全文
摘要:Arduino学习笔记 寒假打算玩玩看,不知道能玩出个啥( 手边的设备,具体用法以后慢慢补充 ARDUINO UNO 单片机 ATMEGA328 32kb闪存 2kb RAM 0 - 13 数字输入输出 A0 - A5 模拟输入输出 3 5 6 9 10 11 pwm Vin 稳压前电压输入 Vou
阅读全文