- 博客(7)
- 收藏
- 关注
原创 容斥原理在编程中的应用
给你一个正整数 n ,请你计算在 [1,n] 范围内能被 3、5、7 整除的所有整数之和。返回一个整数,用于表示给定范围内所有满足约束条件的数字之和。考虑在区间 [1,n][1, n][1,n] 内能被数 mmm 整除的整数,从小到大排序后成为一个等差数列,和为:等差数列求和。有重复时只计算一次。有 A+B+C - A∩B - B∩C - C∩A + A∩B∩C。
2023-10-17 08:36:06
229
原创 小白零基础入门之实现一个函数类(仿函数)
仿函数即为函数对象,一个能使用函数功能的类主要实现是通过operator()运算符达到调用函数的效果。
2023-10-09 17:16:54
162
1
原创 指针的类型转换和绕晕人的指针
指针:内存地址以字节为单位(提供操作内存的机会),在不同操作系统下; 32位cpu寻址能力2^32,指针为4个字节; 64位cpu寻址能力2^64, 指针为8字节。 指针的类型转换 #include<iostream> int main() { unsigned ua{ 999 }; int a{ 666 }; int* ptrA{ &a }; unsigned* ptrUa{&ua}; ptrA = (int*)&ua; *ptrA = -1
2022-03-13 13:33:23
2112
原创 位运算的实践运用
#include<iostream> #include<bitset> class Light{ private: unsigned int Switch; public: Light(unsigned int S) { this->Switch = S; } void ControlEveryL(unsigned int number); void OpenOneBlock(unsigned int target); void CloseOneBloc.
2022-03-10 20:19:56
146
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅