[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
草稿箱存不下你了
<>1、函数的调用
当一个函数运行期间调用另一个函数时,在运行被调函数之前,系统需要完成三件事:
* 1、将所有的实际参数,返回地址等信息传递给被调函数保存
* 2、为被调函数的局部变量(也包含形参)分配存储空间
* 3、将控制权转移到被调函数的入口
从主调函数返回被调函数之前,系统要完成三件事
* 1、保存被调函数的返回结果
* 2、释放被调函数所占的存储空间
* 3、依照被调函数保存的返回地址将控制权转移到主调函数
当有多个函数相互调用时,按照后调先返回的原则,上述函数之间信息传递和控制转移必须借助栈
来实现,即系统将整个程序运行时所需的数据空间安排在一个栈中,每当调用一个函数时,就在栈顶分配一个存储区,进行压栈操作,每当一个函数退出时,就释放它的存储区,就进行出栈操作,使运行的函数永远都在栈顶位置,
伪代码分析;
#include<stdio.h> void fun() { 语句A; g(); 语句B; } void g() { 语句c; } int main() {
fun(); return 0; }
分析;
#include<stdio.h> #include<stdlib.h> void f(); void g(); void k(); void f() {
printf("ffffff\n"); g(); printf("111111\n"); } void g() { printf("ggggg\n"); k()
; printf("22222222\n"); } void k() { printf("kkkkkk\n"); printf("3333333\n"); }
int main() { f(); return 0; }
运算结果:
分析;
<>2、递归
定义:一个函数直接或者间接调用自己
递归三个条件:
* 1、递归必须有一个明确的中止条件
* 2、该函数所处理的数据规模必须在递减
* 3、这个转化必须是递减的
应用 :汉诺塔:
先把A柱子上的前n-1个借助c从a移动到b
将a驻子上的第n个盘子直接移动到c
再将b柱子上的n-1歌盘子借助a移动到c
代码有时间再补 应用:场景: 树和森林就是递归的方式定义的 树和图的的很多算法就是以递归来实现的 很多数学公式就是以递归的方式的定义的 斐波拉锲