c/c++
风 先生
这个作者很懒,什么都没留下…
展开
-
Φ(x)累积密度函数的C ++实现
正态分布函数正态分布(Normal distribution)又名高斯分布(Gaussian distribution),是一个在数学、物理及工程等领域都非常重要的概率分布,在统计学的许多方面有着重大的影响力。若随机变量X服从一个数学期望为μ、标准方差为σ2的高斯分布,记为: X∼N(N(μ,σ2),σ2)X∼N(N(μ,σ2),σ2)X∼N(N(μ,σ^2),σ^2) 则其概率密...原创 2018-06-23 17:12:51 · 3003 阅读 · 0 评论 -
Solution of 1117. Eddington Number(25)
1117. Eddington Number(25)British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, he has even defined an “Eddington number”, E – that is, the maximum integer原创 2016-09-13 12:03:57 · 1040 阅读 · 0 评论 -
solution Of 1116. Come on! Let's C (20)
1116. Come on! Let’s C (20)“Let’s C” is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, th原创 2016-09-12 10:45:32 · 676 阅读 · 0 评论 -
solution Of 1014. Waiting in Line (30)
1014. Waiting in Line (30)Suppose a bank has N windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. The rules for the customers to wai原创 2016-06-22 12:31:37 · 730 阅读 · 0 评论 -
solution Of 1055. The World's Richest (25)
1055. The World’s Richest (25)Forbes magazine publishes every year its list of billionaires based on the annual ranking of the world’s wealthiest people. Now you are supposed to simulate this job, but原创 2016-06-22 02:04:08 · 429 阅读 · 0 评论 -
solution Of 1066. Root of AVL Tree (25)
1066. Root of AVL Tree (25)An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by mor原创 2016-06-21 15:16:34 · 398 阅读 · 0 评论 -
solution Of 1018. Public Bike Management (30)
1018. Public Bike Management (30)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return原创 2016-07-06 16:50:09 · 543 阅读 · 0 评论 -
solution Of 1022. Digital Library (30)
1022. Digital Library (30)A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned a原创 2016-06-20 22:49:42 · 484 阅读 · 0 评论 -
solution Of 1051. Pop Sequence (25)
1051. Pop Sequence (25)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possib原创 2016-06-19 23:10:10 · 285 阅读 · 0 评论 -
solution Of 1019. General Palindromic Number (20)
1019. General Palindromic Number (20)A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single d原创 2016-06-19 20:32:54 · 342 阅读 · 0 评论 -
C/C++中extern关键字详解
1 基本解释:extern可以置于变量或者函数前,以标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义。此外extern也可用来进行链接指定。 也就是说extern有两个作用,第一个,当它与”C”一起连用时,如: extern “C” void fun(int a, int b);则告诉编译器在编译fun这个函数名时按着C的规则去翻译相应的函数名而不是C转载 2016-06-19 10:36:29 · 303 阅读 · 0 评论 -
solution Of 1091. Acute Stroke (30)
1091. Acute Stroke (30)One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI s原创 2016-06-17 22:54:39 · 324 阅读 · 0 评论 -
opencv在图片中写入文字
由于一个小项目的需要,我得在把1000多个账号粘贴到特定的图片上打印出来,简直可怕。 系统 : windows7 环境 : vs2010+opencv-2.4.0 opencv+vs配置这个就不多说什么了 (1)配置系统变量 (2)添加包含目录、库目录 (3)添加附加依赖项(.lib) 有疑问可以参考: http://www.cnblogs.com/freedomshe/ar原创 2016-07-03 22:14:07 · 22056 阅读 · 0 评论 -
solution Of 1096. Consecutive Factors (20)
1096. Consecutive Factors (20)Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3*5*6*7, where 5, 6, and 7 are the three co原创 2016-06-17 16:28:02 · 390 阅读 · 0 评论 -
solution Of 1103. Integer Factorization (30)
1103. Integer Factorization (30)The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K-P fact原创 2016-06-16 23:04:25 · 422 阅读 · 0 评论 -
C++读取CSV表格
其实原始的问题是要对excel的文件进行处理的。看来一下需要处理的问题的文件的内容,结构很简单。 一瞬间懒癌发作,直接把文件格式转成了csv。 CSV是一种Excel表格的导出格式,在Excel表格的菜单栏中点击文件->另存为会弹出一个文件夹浏览窗口,在下拉框中可以选择保存格式,其中有一个就是.CSV(逗号分隔符)选项。CSV表格很官方的规则: 1 开头是不留空,以行为单位。 2 可含或原创 2016-07-03 02:14:46 · 6077 阅读 · 0 评论 -
Solution of 1118. Birds in Forest (25)
1118. Birds in Forest (25)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the sci原创 2016-09-15 21:33:35 · 294 阅读 · 0 评论 -
Solution of 1119. Pre- and Post-order Traversals (30)
1119. Pre- and Post-order Traversals (30)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder trave原创 2016-09-16 01:11:01 · 826 阅读 · 1 评论 -
solution of hihoCoder #1014 : Trie树
描述小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一本词典,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能对于每一个我给出的字符串,都在这个词典里面找到以这个字符串开头的所有单词呢?”身经百战的小Ho答道:“怎么会不能呢!你每给我一个字符串,我就依次遍历词典里的所有单词,检查你给我的字符串是不原创 2016-10-10 22:55:12 · 398 阅读 · 0 评论 -
Solution of 1144 The Missing Number (20)
1144 The Missing Number (20)Given N integers, you are supposed to find the smallest positive integer that is NOT in the given list.Input Specification:Each input file contains one test case. For...原创 2018-05-19 00:10:49 · 291 阅读 · 0 评论 -
Solution of 1122. Hamiltonian Cycle (25)
1122. Hamiltonian Cycle (25)The “Hamilton cycle problem” is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a “Hamiltonian cycle”.In this problem, you are supp...原创 2018-04-23 01:52:13 · 245 阅读 · 0 评论 -
solution of POJ:1017.Packet
DescriptionA factory produces products packed in square packets of the same height h and of the sizes 1*1, 2*2, 3*3, 4*4, 5*5, 6*6. These products are always delivered to customers in the square parcel原创 2016-11-17 17:23:13 · 501 阅读 · 0 评论 -
solution of POJ: 1328.Radar Installation
DescriptionAssume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locati原创 2016-11-13 23:18:08 · 479 阅读 · 0 评论 -
solution of POJ:3190.Stall Reservations
DescriptionOh those picky N (1 <= N <= 50,000) cows! They are so picky that each one will only be milked over some precise time interval A..B (1 <= A <= B <= 1,000,000), which includes both times A and原创 2016-11-14 13:46:23 · 402 阅读 · 0 评论 -
solution of POJ 2376.Cleaning Shifts
DescriptionFarmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the d原创 2016-11-13 18:17:12 · 468 阅读 · 0 评论 -
solution of POJ:2393.Yogurt factory
DescriptionThe cows have purchased a yogurt factory that makes world-famous Yucky Yogurt. Over the next N (1 <= N <= 10,000) weeks, the price of milk and labor will fluctuate weekly such that it will c原创 2016-11-16 18:15:12 · 426 阅读 · 0 评论 -
solution of POJ:3187.Backward Digit Sums
3187.Backward Digit SumsDescriptionFJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new原创 2016-11-12 23:16:06 · 613 阅读 · 0 评论 -
solution of LeetCode:146 LRU Cache
LeetCode:LRU CacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) o原创 2016-11-08 22:50:37 · 428 阅读 · 0 评论 -
判断一棵二叉树是否为二叉搜索树(BST)
这里先简单介绍一下二叉查找树的性质: 递归定义节点的左子树中任意节点值小于根节点的值,节点的右子树中任意节点值大于根节点,且当前节点左右子树都必须是二叉查找树,不允许存在重复节点。 假设:节点的数据结构:struct node{ int value; node* left; node* right;};方法1(错误示范:自己踩的坑)首先BST是一个递归定义:这样我们首先原创 2016-11-11 23:11:23 · 28184 阅读 · 6 评论 -
RapidXml使用(备忘)
好吧,先来说一下,为什么我要选择RapidXml来进行本地xml文件的解析:对,没有错,接下来你看到的很长的一大段都摘自于: http://stackoverflow.com/questions/9387610/what-xml-parser-should-i-use-in-c/9387612#9387612 So the first question is this: What do yo转载 2016-10-27 21:09:42 · 912 阅读 · 0 评论 -
lower_bound/upper_bound(STL)
其实我们这是以一个简单的算法题开始的: 一个存在重复数据的有序数组A,现在给定一个数字key,我要找到数组中与该给定值差的绝对值最小的那个数的最开始的位置。 case: 给定数组A:1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 6 给定数值key:5 输出:9(即第一个4的位置)结题思路 : 题意要求我们返回数组A中与该给定的Key的差的绝对原创 2016-10-26 20:42:50 · 376 阅读 · 0 评论 -
c++ 如何批量初始化数组
fill函数,fill_n函数与memset函数的区别对,没有错,我就是懒得写那几行循环的代码.我们首先定义两个数组:int a[1000];char str[1000];现在要把a里面1000个全部初始化为5;str里面全部初始化为a;int a[1000] = {0}; char str[1000] = {'a'}; 但这样只有第一个元素被设置,其余999个自动默认是int 的0;我们先来看原创 2016-10-16 12:06:23 · 20587 阅读 · 1 评论 -
拓扑排序的原理及其实现
这里要从一道题目开始说起题目大意:我们的系统现在有一连串的事务需要处理,但事务之间存在依赖性,问我们的事务应该以怎样的顺序进行处理。 第一行读入两个整数,节点总数m,依赖项的个数n;接下来读入n行数据,每行数据:A size BCDE,表示BCDE完成以后才能处理A,size表示接下来的节点个数输入: 13 11 1 1 0 5 2 0 3 0 1 2 3 1 2 4 2 5 6 6原创 2016-11-05 16:33:48 · 867 阅读 · 0 评论 -
solution of AOJ 0033:ball (《挑战程序设计竞赛(第2版)》)
有一个形似央视大楼(Orz)的筒,从A口可以放球,放进去的球可通过挡板DE使其掉进B裤管或C裤管里,现有带1-10标号的球按给定顺序从A口放入,问是否有一种控制挡板的策略可以使B裤管和C裤管中的球从下往上标号递增。 输入: 第一行输入数据组数N。接下来N行为N组具体数据,每组数据中有10个整数,代表球的放入顺序。 输出: 对于每组数据,若策略存在,输出YES;若不存在,输出NO Samp原创 2016-10-14 11:19:46 · 550 阅读 · 0 评论 -
solution Of 1101. Quick Sort (25)
1101. Quick Sort (25)There is a classical process named partition in the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot原创 2016-06-16 00:01:36 · 473 阅读 · 0 评论 -
solution Of 1107. Social Clusters (30)
1107. Social Clusters (30)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A “social cluster” is a set of p原创 2016-06-15 17:07:15 · 457 阅读 · 0 评论 -
solution Of Pat 1033. To Fill or Not to Fill (25)
1033. To Fill or Not to Fill (25)With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way原创 2016-03-29 01:21:40 · 943 阅读 · 0 评论 -
solution Of 1068. Find More Coins (30)
1068. Find More Coins (30) Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of原创 2016-04-26 13:25:02 · 446 阅读 · 0 评论 -
solution Of 1076. Forwards on Weibo (30)
1076. Forwards on Weibo (30)Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with f原创 2016-04-12 23:10:28 · 257 阅读 · 0 评论 -
solution Of Pat 1052. Linked List Sorting (25)
1052. Linked List Sorting (25)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to原创 2016-03-26 22:39:22 · 307 阅读 · 0 评论