![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c语言与算法
qq_52932931
这个作者很懒,什么都没留下…
展开
-
2021-04-09
//给出N个整数,再给出M个整数,问这个M个数中的每个数分别是否是N个整数中出现过。 //采用一般的遍历法时间复杂度为O(mn),而采用哈希表,用空间换取时间,只需要O(m+n) #include<stdio.h> #include<stdlib.h> const int maxn = 100010; bool hashtable[maxn] = { false }; int main(){ int n, m, x; scanf("%d%d", &n, &m);原创 2021-04-09 11:38:50 · 63 阅读 · 0 评论 -
p进制的num转化为十进制的J
while (num != 0){//将p进制的num转化为十进制的j j += (num % 10)*product; num = num / 10; product = product*P; }码片原创 2021-04-07 15:39:09 · 70 阅读 · 0 评论 -
日期处理
在这里#include<stdio.h> #include<math.h> #include<stdlib.h> int month[13][2] = { (0, 0), (31, 31), (28, 29), (31, 31), (30, 30), (31, 31), (30, 30), (31, 31), (30, 30), (31, 31), (30, 30), (31, 31), (30, 30) };//平年和闰年每月的天数 bool isleap(int原创 2021-04-07 14:16:41 · 49 阅读 · 0 评论 -
c语言中结构体中构造方法用来初始化
## 结构体的构造函数的用途和构造方法 结构体中可以有构造函数,用于给结构体赋于初始值。 #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> struct student{ int id; char gender; student(){} student(int _id,char _gender){ id = _id; gender = _id; }原创 2021-04-07 08:26:46 · 279 阅读 · 0 评论