10 2022 档案

摘要:经典问题合集1. 累加和(连续整数、分数、加减交替) 1.1 连续整数 计算1+2+....100。 #include <stdio.h> int main() { int i,sum=0; for(i=1;i<=100;i++) { sum=sum+i; } printf("%d",sum); return 阅读全文
posted @ 2022-10-14 12:30 找回那所有、 阅读(90) 评论(0) 推荐(0) 编辑
摘要:递归算法定义:函数中可调用其他函数,递归特指函数中调用自身 注意点:需定义终止条件( if (...) 调用自身),否则会无休止下去 题型:汉诺塔、青蛙跳台阶、蜜蜂回家、求阶乘(也可用循环) 1. 汉诺塔问题:(拓展:对搬动次数计数) 有标记为1, 2, 3 的三根柱子,按规则摆放大小盘所需的步骤为: st 阅读全文
posted @ 2022-10-14 10:58 找回那所有、 阅读(48) 评论(0) 推荐(0) 编辑
摘要:*指向函数的指针定义指向函数的指针变量,形式上用(*p)取代max,int(*p)(int,int) 使p指向max函数,p=max 通过指针变量调用max函数,形式上用(*p)取代max,c=(*p)(a,b) 1. 通过指针变量访问它所指向的函数实现求出两个整数中的大者: #include <stdio.h> 阅读全文
posted @ 2022-10-10 11:25 找回那所有、 阅读(40) 评论(0) 推荐(0) 编辑
摘要:*指针与多维数组每一维的数组名为 a[i]。 a[i]+1 是 a[i][1] 的地址;a[i]+j 是 a[i][j] 的地址。*(a[i]+1) 是 a[i][1] 的间接引用形式;*(a[i]+j) 是 a[i][j] 的间接引用形式。 a是 a[0] 的地址,a+1 是 a[1] 的地址,a+i 是 a[i 阅读全文
posted @ 2022-10-08 12:00 找回那所有、 阅读(65) 评论(0) 推荐(0) 编辑
摘要:指针与字符串数组字符指针的定义和输出: 法一:不使用指针 #include <stdio.h> #include <string.h> int main() { char str[]="I love China!";//字符串数组末位多一字节填入'\0' //char str[]={'I','l','o','v', 阅读全文
posted @ 2022-10-08 11:59 找回那所有、 阅读(76) 评论(0) 推荐(0) 编辑
摘要:指针与整型数组1. 输入10个整数,将其中最小的数与第一个数对换,把最大的一个数与最后一个数对换。 #include <stdio.h> int main() { void in_num(int *x); void out_num(int *x); void exchange(int *x); int a[10] 阅读全文
posted @ 2022-10-08 11:57 找回那所有、 阅读(118) 评论(0) 推荐(0) 编辑
摘要:指针与函数跨函数间接引用局部变量的一般步骤: 主调函数中,将变量的地址作为实参 swap(&a,&b);如为数组,写为 fun(&a[0]) 或 fun(a),调用时只需传地址 被调函数中,定义指针形参 int *p 被调函数中,对指针形参内容改写完成需求 *p=...;如为数组,写为 *(p+i) =... 阅读全文
posted @ 2022-10-08 11:49 找回那所有、 阅读(81) 评论(0) 推荐(0) 编辑
摘要:group by 专题1. 涉及 “最多/最大”,即比其他所有(all)都大(>=): 常和 having count() 搭配,作为一个判断条件;还可搭配 max(),all() 。 力扣586: select customer_number from Orders group by customer_number h 阅读全文
posted @ 2022-10-05 10:39 找回那所有、 阅读(24) 评论(0) 推荐(0) 编辑
摘要:rank() 排序专题有三种排序的窗口函数: row_number():1, 2, 3rank():1, 2, 2, 4dense_rank():1, 2, 2, 3 rank()括号内无需加字段,排序字段在over()括号中添加。 当新字段以rank命名时,加引号'rank'。 力扣178: select score, 阅读全文
posted @ 2022-10-04 21:00 找回那所有、 阅读(53) 评论(0) 推荐(0) 编辑
摘要:连续专题查找连续的记录,连续项可能是确定的,也可能是不确定的。 有几种思路: 原理上,常用 lag / lead 函数;也可用 self join;也可以用 in 处理。 技巧上,针对不定项连续问题,可做差后分组 diff。 1. 定项连续:即连续项确定。 力扣603: select seat_id fro 阅读全文
posted @ 2022-10-03 17:56 找回那所有、 阅读(19) 评论(0) 推荐(0) 编辑
摘要:join 三表连接综训有时我们会对三个表做连接。 力扣585:(这里是复杂方法) select round(sum(TIV_2016),2) as TIV_2016 from (select distinct i1.PID,i1.TIV_2016 from insurance i1,insurance i2,insura 阅读全文
posted @ 2022-10-03 14:49 找回那所有、 阅读(141) 评论(0) 推荐(0) 编辑
摘要:join 新表连接综训对于较复杂的题,按需求处理产生新表,再连接。 往往滑动平均 / 累加,都需要处理产生一张新表。 力扣1126: 关键点1:新增平均列 with tmp1 as (select business_id,event_type,avg(occurences) as avg_occurences from 阅读全文
posted @ 2022-10-01 18:11 找回那所有、 阅读(31) 评论(0) 推荐(0) 编辑
摘要:最值专题“最大/最小” 问题,可和 group by 搭配 max/min ,where 互相改写: 力扣1070: select distinct product_id,year as first_year,quantity,price from (select *,rank() over (partit 阅读全文
posted @ 2022-10-01 15:58 找回那所有、 阅读(17) 评论(0) 推荐(0) 编辑

这里到底了哦~(●'◡'●)
点击右上角即可分享
微信分享提示