积少成多

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

06 2016 档案

摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2, 阅读全文
posted @ 2016-06-28 22:07 x7b5g 阅读(159) 评论(0) 推荐(0)

摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple 阅读全文
posted @ 2016-06-28 22:01 x7b5g 阅读(126) 评论(0) 推荐(0)

摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2016-06-28 21:49 x7b5g 阅读(197) 评论(0) 推荐(0)

摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2016-06-28 17:25 x7b5g 阅读(217) 评论(0) 推荐(0)

摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longes 阅读全文
posted @ 2016-06-27 23:16 x7b5g 阅读(162) 评论(0) 推荐(0)

摘要:Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2016-06-27 23:09 x7b5g 阅读(209) 评论(0) 推荐(0)

摘要:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled wit 阅读全文
posted @ 2016-06-27 22:29 x7b5g 阅读(174) 评论(0) 推荐(0)

摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2016-06-27 21:48 x7b5g 阅读(183) 评论(0) 推荐(0)

摘要:Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. 利用:中序+后序遍历 c 阅读全文
posted @ 2016-06-26 22:50 x7b5g 阅读(146) 评论(0) 推荐(0)

摘要:Given preorder and inorder traversal of a tree, construct the binary tree. 基本功: 利用前序和中序构建二叉树 , code 阅读全文
posted @ 2016-06-26 22:46 x7b5g 阅读(226) 评论(0) 推荐(0)

摘要:Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, ex 阅读全文
posted @ 2016-06-26 22:44 x7b5g 阅读(172) 评论(0) 推荐(0)

摘要:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa 阅读全文
posted @ 2016-06-26 22:24 x7b5g 阅读(144) 评论(0) 推荐(0)

摘要:Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: 思路: 将一个二叉树 就地 压成"链表"的结构; 阅读全文
posted @ 2016-06-26 22:20 x7b5g 阅读(137) 评论(0) 推荐(0)

摘要:Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 升序数组a[],构造平衡二叉树,左右子树高度差不超过1. 思路: 利用先序构建二叉树的方法,将数组的中间 阅读全文
posted @ 2016-06-26 21:57 x7b5g 阅读(148) 评论(0) 推荐(0)

摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2016-06-26 21:44 x7b5g 阅读(203) 评论(0) 推荐(0)

摘要:Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. Note:A solution using O(n) space i 阅读全文
posted @ 2016-06-26 21:37 x7b5g 阅读(492) 评论(0) 推荐(0)

摘要:笔记另写: code: 前序线索化 阅读全文
posted @ 2016-06-26 21:16 x7b5g 阅读(490) 评论(0) 推荐(0)

摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文
posted @ 2016-06-26 21:14 x7b5g 阅读(232) 评论(0) 推荐(0)

摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2016-06-26 21:01 x7b5g 阅读(175) 评论(0) 推荐(0)

摘要:Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2016-06-26 20:37 x7b5g 阅读(198) 评论(0) 推荐(0)

摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, 阅读全文
posted @ 2016-06-26 20:01 x7b5g 阅读(123) 评论(0) 推荐(0)

摘要:Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. 阅读全文
posted @ 2016-06-26 19:50 x7b5g 阅读(147) 评论(0) 推荐(0)

摘要:Description: Count the number of prime numbers less than a non-negative number, n. 找质数的问题. [http://www.cnblogs.com/li-daphne/p/5549557.html]我在这里有过分析 ! 阅读全文
posted @ 2016-06-26 19:27 x7b5g 阅读(153) 评论(0) 推荐(0)

摘要:整型数组,元素有正数和负数。数组中一个或连续的多个整数组成一个子数组,求所有子数组中最大值。 动态规划, 状态转移方程,max[].size = nums.size() max[i]= max[i-1]+nums[i],if max[i-1]>0 nums[i], if max[i-1]<=0 这样 阅读全文
posted @ 2016-06-23 21:58 x7b5g 阅读(186) 评论(0) 推荐(0)

摘要:剑指offer给出两类方法: 1,借助快排的思想,需要修改输入数组的元素,时间复杂度O(n) 2,借助STL中set或者multiset,因为它们的底层数据结构是红黑树实现的,插入数据时间复杂度为O(logk),所以总的时间复杂度为O(nlogn); 方法2的代码如下: 阅读全文
posted @ 2016-06-23 21:46 x7b5g 阅读(202) 评论(0) 推荐(0)

摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2016-06-23 21:30 x7b5g 阅读(146) 评论(0) 推荐(0)

摘要:There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh 阅读全文
posted @ 2016-06-23 21:18 x7b5g 阅读(207) 评论(0) 推荐(0)

摘要:单例模式? 只能实现一个实例的类成为单例。 muduo库中单例模式实现 阅读全文
posted @ 2016-06-23 20:52 x7b5g 阅读(182) 评论(0) 推荐(0)

摘要:题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有这个整数? 思路:查找7 从右上角的数组开始判断:9>7,又因为每一列从上到下递增,所以这一列淘汰 接着第三列也被排除 现在右上角为2 阅读全文
posted @ 2016-06-23 20:03 x7b5g 阅读(196) 评论(0) 推荐(0)

摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2016-06-23 19:38 x7b5g 阅读(110) 评论(0) 推荐(0)

摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2016-06-23 18:42 x7b5g 阅读(167) 评论(0) 推荐(0)

摘要:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be 阅读全文
posted @ 2016-06-23 11:10 x7b5g 阅读(183) 评论(0) 推荐(0)

摘要:Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. Credi 阅读全文
posted @ 2016-06-23 10:27 x7b5g 阅读(140) 评论(0) 推荐(0)

摘要:c++11中提供了to_string函数,定义在string中, 重载了一大片, 另外,标准库中string有一批函数,特别难用. 阅读全文
posted @ 2016-06-23 10:23 x7b5g 阅读(386) 评论(0) 推荐(0)

摘要:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements ofnums except n 阅读全文
posted @ 2016-06-22 22:11 x7b5g 阅读(161) 评论(0) 推荐(0)

摘要:Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: 347. Top K Fr 阅读全文
posted @ 2016-06-22 22:03 x7b5g 阅读(177) 评论(0) 推荐(0)

摘要:Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c" click to show co 阅读全文
posted @ 2016-06-22 20:25 x7b5g 阅读(175) 评论(0) 推荐(0)

摘要:Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: Note: All inputs will be i 阅读全文
posted @ 2016-06-22 20:06 x7b5g 阅读(156) 评论(0) 推荐(0)

摘要:Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the". Update (2015-02-12):For C pr 阅读全文
posted @ 2016-06-22 19:27 x7b5g 阅读(155) 评论(0) 推荐(0)

摘要:Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = 阅读全文
posted @ 2016-06-22 18:20 x7b5g 阅读(152) 评论(0) 推荐(0)

摘要:Implement a basic calculator to evaluate a simple expression string. The expression string contains only non-negative integers, +, -, *, / operators a 阅读全文
posted @ 2016-06-22 18:18 x7b5g 阅读(149) 评论(0) 推荐(0)

摘要:Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below 阅读全文
posted @ 2016-06-22 18:08 x7b5g 阅读(171) 评论(0) 推荐(0)

摘要:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the 阅读全文
posted @ 2016-06-22 17:57 x7b5g 阅读(151) 评论(0) 推荐(0)

摘要:Write a function to find the longest common prefix string amongst an array of strings 题目:找vector中最长公共前缀, 思路:模拟比较的过程,我们可以看到这些. 按照数组中的第一个字符串开始进行比较, 对第一个 阅读全文
posted @ 2016-06-22 17:52 x7b5g 阅读(152) 评论(0) 推荐(0)

摘要:Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element i 阅读全文
posted @ 2016-06-22 17:16 x7b5g 阅读(159) 评论(0) 推荐(0)

摘要:Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each elemen 阅读全文
posted @ 2016-06-22 17:13 x7b5g 阅读(148) 评论(0) 推荐(0)

摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then l 阅读全文
posted @ 2016-06-22 16:22 x7b5g 阅读(151) 评论(0) 推荐(0)

摘要:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null. Return a deep copy 阅读全文
posted @ 2016-06-22 16:15 x7b5g 阅读(110) 评论(0) 推荐(0)

摘要:计数排序 桶排序 阅读全文
posted @ 2016-06-22 15:40 x7b5g 阅读(174) 评论(0) 推荐(0)

摘要:Sort a linked list in O(n log n) time using constant space complexity. 题目:有时间和空间复杂度限制 单链表适合利用归并排序, 双向链表适合利用快速排序, 复用mergeTwoList()代码 1,利用fast/slow方法找到链 阅读全文
posted @ 2016-06-22 15:35 x7b5g 阅读(163) 评论(0) 推荐(0)

摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 合并k个链表形成一个已排序链表 思路: 如何合并两个有序链表?经典merge算法: 对vector中的 阅读全文
posted @ 2016-06-22 15:26 x7b5g 阅读(193) 评论(0) 推荐(0)

摘要:Sort a linked list using insertion sort. 思路: 怎么判断链表开始? 怎么判断链表结束? 定义dummy假的头节点,这样的话直接就有了链表头dummy.next 怎么将curr指向的节点插入到in指向的位置? 四步就可以完成:ListNode *tmp = c 阅读全文
posted @ 2016-06-22 15:15 x7b5g 阅读(164) 评论(0) 推荐(0)

摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文
posted @ 2016-06-22 14:58 x7b5g 阅读(272) 评论(0) 推荐(0)

摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single 阅读全文
posted @ 2016-06-22 14:43 x7b5g 阅读(181) 评论(0) 推荐(0)

摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 题目:将升序的链表,转化为BST(note:此BST要求是高度平衡,就是树种左右 阅读全文
posted @ 2016-06-22 14:26 x7b5g 阅读(206) 评论(0) 推荐(0)

摘要:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For 阅读全文
posted @ 2016-06-22 14:08 x7b5g 阅读(167) 评论(0) 推荐(0)

摘要:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the 阅读全文
posted @ 2016-06-22 13:58 x7b5g 阅读(173) 评论(0) 推荐(0)

摘要:反转链表 注意是借用 假的头节点,这样算法判断开始和结束,就好很多了. 借用头插法. []dummy/head [] [] [] [] head curr 阅读全文
posted @ 2016-06-22 13:52 x7b5g 阅读(142) 评论(0) 推荐(0)

摘要:链表节点定义: 就地逆置 阅读全文
posted @ 2016-06-22 13:49 x7b5g 阅读(296) 评论(0) 推荐(0)

摘要:内容主要来自搜狗实验室技术交流文档, 编写链接数巨大的高负载服务器程序时,经典的多线程模式和select模式都不再适合了.应该采用epool/kqueue/dev_pool来捕获IO事件. 问题的由来: C10K问题的最大特点就是:设计不够良好的程序,其性能和链接数以及机器性能的关系是非线性的. 例 阅读全文
posted @ 2016-06-21 15:29 x7b5g 阅读(5004) 评论(0) 推荐(0)

摘要:linux提供了一种特殊的文件系统procfs,通常以/proc目录的形式呈现。该目录中包含了许多特殊文件用来对驱动程序和内核信息进行更高层的访问。只要应用程序有正确的访问全息,就可以通过读写这些文件获得信息或设置参数。 例如/proc/cpuinfo给出的是cpu的详细信息: 我的笔记本是4核机器 阅读全文
posted @ 2016-06-15 14:35 x7b5g 阅读(298) 评论(0) 推荐(0)

摘要:来自https://www.zhihu.com/question/31459750 答主解释说:不能指望volatile能解决多线程竞争问题,除非所用的环境系统不可靠才会为了保险加上volatile, 或者从极限效率考虑来实现很底层的接口,这要求编写者对逻辑走向很清楚,不然会出错。 c++11标准明 阅读全文
posted @ 2016-06-14 14:16 x7b5g 阅读(1530) 评论(0) 推荐(0)

摘要:在csapp学习或者其他linux底层编程的过程中,一般都会举一些多线程或多进程的例子,配合底层同步原语、系统调用api来解释怎么创建多线程/多进程。 但是这些例子和实际项目中所用到的多线程/多进程编程知识有很大的距离(小例子很好理解,但是为了完成一个任务基本就没有什么思路了)。 我学习多线程/多进 阅读全文
posted @ 2016-06-14 10:47 x7b5g 阅读(8716) 评论(0) 推荐(1)

摘要:编解码器(英语:codec)指的是一个能够对一个信号或者一个数据流进行编解码操作的设备或者程序。这里指的变换既包括将信号或者数据流进行编码(通常是为了传输、存储或者加密)或者提获取到一个编码流的操作,也包括为了观察或者处理从这个编码流中恢复适合观察或操作的形式的操作。编解码器经常用在视频会议和流媒体 阅读全文
posted @ 2016-06-13 13:36 x7b5g 阅读(1831) 评论(0) 推荐(0)

摘要:c++中 cin.peek()函数 其返回值是一个char型的字符,返回值是指针指向的当前字符, 但是只是观测,指针任停留在当前位置,并不后移.如果要访问的字符是文件结束符,则函数值是EOF(-1); 功能:从输入流中读取一个字符,但是该字符并未从输入流中删除, 如果把输入流比作栈类, 那么这里的p 阅读全文
posted @ 2016-06-12 12:46 x7b5g 阅读(3021) 评论(0) 推荐(0)

摘要:\r回车符 \n换行符 由于历史原因,windows下的换行符为\r\n linux或者html等开源或公开标准的换行符是\n 为什么windows下的回车换行是\r\n? 第一台打印机,每一行打印完了在打印第二行之前,喷墨的喷头需要西安回到这一行的行首,这叫回车\r 然后跳刀下一行,这叫换行\n 阅读全文
posted @ 2016-06-12 11:37 x7b5g 阅读(243) 评论(0) 推荐(0)

摘要:很好用,推荐大家都来用. http://www.csdn.net/article/2014-05-05/2819623 阅读全文
posted @ 2016-06-08 22:07 x7b5g 阅读(165) 评论(0) 推荐(0)

摘要:来自http://zh.cppreference.com/w/cpp/iterator 迭代器库提供了5种迭代器的定义,同时还提供了迭代器特征、适配器及其相关的工具函数。 迭代器共有5种:InputIterator,OutIterator,ForwardInterator,Bidirectional 阅读全文
posted @ 2016-06-07 20:03 x7b5g 阅读(388) 评论(0) 推荐(0)

摘要:Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, 阅读全文
posted @ 2016-06-07 17:53 x7b5g 阅读(211) 评论(0) 推荐(0)

摘要:A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文
posted @ 2016-06-07 15:00 x7b5g 阅读(117) 评论(0) 推荐(0)

摘要:多写限制条件可以加快调试速度。 Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How an 阅读全文
posted @ 2016-06-07 14:35 x7b5g 阅读(153) 评论(0) 推荐(0)

摘要:Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Find the minimum element. 阅读全文
posted @ 2016-06-07 14:05 x7b5g 阅读(136) 评论(0) 推荐(0)

摘要:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a functio 阅读全文
posted @ 2016-06-07 12:56 x7b5g 阅读(178) 评论(0) 推荐(0)

摘要:uppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target val 阅读全文
posted @ 2016-06-07 11:23 x7b5g 阅读(231) 评论(0) 推荐(0)

摘要:uml的构造包含3种 事物4种:结构,行为,分组,注释事物 关系4种:泛化,实现,依赖,关联, 图10种,用例图,类图,对象,包,组件,部署,状态,活动,序列,协作 事物是对模型中最具代表性的成分的抽象,关系把事物结合到一起,图聚集了相关的事物 下面说最常见的关系:类与类,类与接口,接口与接口之间, 阅读全文
posted @ 2016-06-05 18:27 x7b5g 阅读(330) 评论(0) 推荐(0)

摘要:当析构函数遇到多线程,当一个对象能被多个线程同时看到,那么对象的销毁时机就变得模糊不清了,可能出现多种竞争条件race condition: 在即将析构一个对象时,如何得知此刻是 否有别的线程正在执行该对象的成员函数 如何保证在执行成员函数期间,对象不会在另一个线程被析构 在调用某个对象的成员函数之 阅读全文
posted @ 2016-06-05 11:43 x7b5g 阅读(344) 评论(0) 推荐(0)

摘要:来自https://www.zhihu.com/question/24116967?q=linux%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%20%E8%99%9A%E5%81%87%E5%94%A4%E9%86%92%20%E9%97%AE%E9%A2%98%3F%E6%88%9 阅读全文
posted @ 2016-06-04 14:58 x7b5g 阅读(1202) 评论(0) 推荐(0)

摘要:解释一下什么是虚假唤醒? 说具体的例子,比较容易说通. pthread_mutex_t lock; pthread_cond_t notempty; pthread_cond_t notfull; void *producer(void *data){ for(int i = 0;i<=16;i++ 阅读全文
posted @ 2016-06-04 13:51 x7b5g 阅读(1846) 评论(0) 推荐(0)

摘要:Linux互斥锁、条件变量和信号量 来自http://kongweile.iteye.com/blog/1155490 http://www.cnblogs.com/qingxia/archive/2012/08/30/2663791.html Linux互斥锁、条件变量和信号量 来自http:// 阅读全文
posted @ 2016-06-04 11:22 x7b5g 阅读(1563) 评论(0) 推荐(0)

摘要:给定一个树的数组表示,按照前序,空节点用-1表示 例如vector<int> nums = {1,2,4,8,-1,-1,9,-1,-1,5,-1,-1,3,6,10,-1,-1,-1,7,-1,11,-1,-1} 算法如下: input: a[] &i #as the current elemen 阅读全文
posted @ 2016-06-02 13:47 x7b5g 阅读(907) 评论(0) 推荐(0)

摘要:来自http://blog.csdn.net/wuzhekai1985/article/details/6725263 问题1,如何判断链表中是否存在环?即上图中从E到R组成的环? 设slow/fast两个指针,同时从链表起点开始,其中快指针fast每次移动长度为2,slow每次移动一个。如果无环, 阅读全文
posted @ 2016-06-01 20:53 x7b5g 阅读(461) 评论(0) 推荐(0)

摘要:大于或等于给定值 长度最小的子数组 leetcode 209 Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum 阅读全文
posted @ 2016-06-01 19:38 x7b5g 阅读(150) 评论(0) 推荐(0)

摘要:什么是位图?来自http://www.cnblogs.com/dolphin0520/archive/2011/10/19/2217369.html 位图就是用一个bit来标记某个元素对应的值,键值就是该元素。最大的好处就是节省了内存空间。 可以利用位图进行排序,输入的数据是有要求的(数据不能重复, 阅读全文
posted @ 2016-06-01 14:52 x7b5g 阅读(585) 评论(0) 推荐(0)

摘要:什么是质数? 只有1和它本身两个因数的数,就是质数(或素数);除了1和它本身以外,还有别的因数的数,就是合数; 质数被用在了哪里? 1,现在密码学,RSA加密问题,bob,alice,蒂夫三个小伙伴之间的通信的问题2、在汽车变速箱齿轮的设计上,相邻的两个大小齿轮齿数最好设计成质数,以增加两齿轮内两个 阅读全文
posted @ 2016-06-01 14:44 x7b5g 阅读(264) 评论(0) 推荐(0)

摘要:一般格式为: 注意函数名是由operator和运算符组成。在上面的一般格式中,operator是关键字,是专门用于重载运算符函数的, 而运算符名称就是提供给用户的预定义运算符。例如operator+就是函数名。 在定义了运算符重载后,函数operator+重载了运算符+,在执行复数c1+c2时,系统 阅读全文
posted @ 2016-06-01 10:25 x7b5g 阅读(247) 评论(0) 推荐(0)