![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++学习之旅
七印miss
这个作者很懒,什么都没留下…
展开
-
单链表
#include <stdio.h>#include <stdlib.h>//definition for the singly-linked list.struct ListNode{ int val; struct ListNode *next;};//convert an array of integer to a singly-linked list.void bui原创 2015-09-26 16:02:33 · 304 阅读 · 0 评论 -
计算定积分的值
1、概率算法1设a, b, c和d是实数,且a ≤ b, c ≤ d, f:[a, b] → [c, d]是一个连续函数,写一概率算法计算积分:#include <iostream>#include <stdlib.h>#include <ctime>#include <cmath>#include <iomanip>#define N 100000000using namespace s原创 2015-09-16 19:58:31 · 1750 阅读 · 0 评论 -
给出一个奇数幻方的解
幻方问题将1,2,…,n的平方个整数填入n*n的棋盘中,是每行每列及两条对角线上的元素之后均相等,满足上述条件的一个安排称为一个n阶幻方。de la Loubere构造奇数阶幻方的方法首先将1放入第一行的中间位置上;若i已填入,则除了以下几种特殊情况外,将i+1填入i所在位置的右边一列的上一行:若i在第一行,则将i+1填入i所在位置的右边一列的底行若i在最后一列,则将i+1填入i的上一行的第一列原创 2015-09-17 23:30:11 · 447 阅读 · 0 评论 -
[LeetCode] Ugly Number
questionWrite a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly sin原创 2015-10-03 23:36:47 · 333 阅读 · 0 评论 -
C/C++随机数的生成
1.获取特定实数区间内的随机浮点数给定区间[a, b],其中a, b为实数,通过下述代码可获得该区间内的随机浮点数xsrand((unsigned)time(NULL));x = a + (b-a)*rand()/(RAND_MAX*1.0);待续原创 2015-09-16 19:03:29 · 397 阅读 · 0 评论 -
文章标题
转载概述所谓bitmap就是用一个bit位来标记某个元素对应的value,而key即是这个元素。由于采用bit为单位来存储数据,因此在可以大大的节省存储空间算法思想32位机器上,一个整形,比如int a;在内存中占32bit,可以用对应的32个bit位来表示十进制的0-31个数,bitmap算法利用这种思想处理大量数据的排序与查询优点: 效率高,不许进行比较和移位占用内存少,比如N=10000转载 2015-10-04 21:51:45 · 425 阅读 · 0 评论 -
线性时间排序
比较排序算法的时间复杂度下界We have now introduced several algorithms that can sort n numbers in O(n lg n) time. Merge sort and heapsort achieve this upper bound in the worst case; quicksort achieves it on average.原创 2015-09-30 22:19:49 · 312 阅读 · 0 评论 -
[LeetCode]186 Excel Sheet Column Title
原题链接QuestionGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB My Answer功能实现函数char* convertToT原创 2015-09-27 14:00:21 · 329 阅读 · 0 评论 -
[LeetCode]171 Excel Sheet Column Number
原题链接QusetionRelated to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB原创 2015-09-27 14:58:28 · 338 阅读 · 0 评论 -
快速排序的四种方式
main functionint main(){ vector<int> vc; srand((unsigned)time(NULL)); int temp = 0; for(int i=0; i<COUNT; ++i){ temp = MIN + rand()%(MAX+MIN-1); vc.push_back(temp);原创 2015-09-15 17:52:34 · 406 阅读 · 0 评论 -
[LeetCode]Contains Duplicate
原题链接questionGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every原创 2015-10-04 20:21:27 · 388 阅读 · 0 评论