- 博客(31)
- 收藏
- 关注
原创 Majority Element
题目描述:给定一个数组,输出出现次数超过数组长度半数的数字。public class Solution { public int majorityElement(int[] num) { int halfLen = num.length/2; HashMap hashMap = new HashMap(); for(in
2014-12-27 15:30:07 406
翻译 极限编程的原则
在HeadFirst java中看到的1、多次经常性的小规模发布。2、避免加入规格没有的功能(不管未来会用到的功能多么诱人)3、先写测试用的程序4、正常工作上下半年5、随时随地重构,也就是改善代码结构6、保持简单7、结伴工作,并经常交流。
2014-12-17 16:29:22 882
原创 LeetCode:Path Sum
今天正好师弟在做这道题,我也就跟着做了。题目描述:给定一个二叉树和一个int型的数字,判断是否存在一条从根节点到叶子节点的路径使得该路径上各节点之和等于该数字。Tip:递归实现/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; *
2014-12-10 21:25:56 429
原创 LeetCode:Reverse Integer
昨天晚上临睡前A掉的。这道题依然很水。题目描述:给定一个int数,将各位翻转以后输出。tip:这道题本身很简单,重要的是如何把情况考虑全面。比如:1、int数翻转以后溢出的问题。2、数的结尾有0,翻转以后如何输出的问题,比如100。代码:public class Solution { final static int max = 2147483647; final st
2014-12-09 11:54:15 632
原创 LeetCode: Single Number
这几天找实习被打击的太厉害了,从今天开始修炼算法。在Leetcode找了半天,只有这一道题会,顺手AC掉。题目描述:有一个数组,里面的数几乎都是成对出现的,但有一个数只有一个,你的任务就是找出这个单个的数。思路:按位异或直接搞定。贴上代码吧,特别简单public class Solution { public int singleNumber(int[] A) {
2014-12-08 22:39:48 732
原创 hdu 1026
#include #include #include #include #include #include #include #include #include #pragma warning( disable : 4996)using namespace
2011-08-14 14:39:27 771
原创 linux 中单引号,双引号及倒引号
最近,搞起了linux.先写几篇读书笔记。首先发一张我在linux下运行的效果1.wenbo@wenbo-desktop:~$ name=path #将name赋值为path2.wenbo@wenbo-desktop:~$ echo name #在屏幕
2011-08-04 19:45:38 7535
原创 hdu 1106
不明白为什么每一道水题我都写的这么辛苦。/* ID:狂人 num:09073355 E-mail:wenboguo@live.com*/#include #include #include #include #include #include #inc
2011-07-16 10:21:28 562
原创 hdu 2561
不知道这是不是HDU上面最水的一道题,直接附代码:/* ID:狂人 num:09073355 E-mail:wenboguo@live.com*/#include #include #include #include #include #include
2011-07-15 18:36:27 734 1
原创 hdu 1234
很早以前就已经做过这道题,不过这次做AC steps又做了一遍,用了stl。挺爽的。直接上代码,没什么好说的。/* ID:狂人 num:09073355 E-mail:wenboguo@live.com*/#include #include #include
2011-07-15 18:06:26 1005
转载 求N!
#include#define N 1000 //要计算的Nlong s[N]={1,1},n=N,t=2,a=1,b=0;int main()//雨中飞燕之作{ for(;a<=*s||(++t<=n?(b=0,a=1):0)
2011-07-04 11:02:30 338
转载 求N!
#include#define N 1000 //要计算的Nlong s[N]={1,1},n=N,t=2,a=1,b=0;int main()//雨中飞燕之作{ for(;a0;)printf("%04d",s[*s]); return 0;}
2011-07-04 10:58:17 401
原创 hdu1029
int hash[Maxl];int main(int argc, char *argv[]){//freopen("aaa.txt", "r", stdin); int n; while(scanf("%d", &n) == 1) { int m; fo
2011-07-03 19:11:56 277
原创 hdu1029
#define Maxl = 10024int hash[Maxl];int main(int argc, char *argv[]){//freopen("aaa.txt", "r", stdin);int n;while(scanf("%d", &n) =
2011-07-03 19:10:52 292
原创 chengxu
#include #include #include #include using namespace std;struct info{ char che; int cnt; bool operator < (const info &a) const { return a.cnt > cnt; }};typedef struct inf
2011-06-24 09:24:00 321
原创 求一道题的解法
<br />素数价值Time Limit : 10000/3000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 63 Accepted Submission(s) : 23Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description我们来定义下一个数的素数价值,假设这个数是N(2<=N<=50000),我
2011-05-11 22:27:00 355
原创 各种排序
转载自:http://www.oschina.net/code/snippet_1434_1721#include 002#include 003structnode 004{ 005 intkey; 006}r[20]; 007 008structrnode 009{ 010 intkey; 011 intpoint; 012}; 013 014main() 015{ 016 voidprint(structnode a[20],intn); 017 intcreat()
2011-03-13 14:03:00 380
原创 转载的迷宫程序
<br />#include<stdio.h> 002 003 #include<iostream> 004 #include<stdlib.h> 005 #include<time.h> 006 #define STACK_INIT_SIZE 1000 007 #define STACKINCREMENT 10 008 #define OK 1 009 #define OVERFLOW 0 010 #define
2011-03-13 13:58:00 441
原创 校赛
<br />今天,感觉自己挺无语的。虽然已经报了退出集训队的打算,但是当结果出来的时候还是不免有些悲伤。能说些什么呢?只能怪自己不够努力。导致了今天的后果。自从从家里回到学校后,就没有再认真训练过了。以后就是一个自由的ACM爱好者了。希望还能有所进步。
2011-03-12 16:47:00 298
原创 priority_queue优先队列的一些用法
<br />#include <iostream>#include <queue>#include <vector>#include <algorithm>using namespace std;class Node{ public: Node(){first = 0;second = 0;} Node(int i, int j) : first(i),second(j){} Node(int i) : first(
2011-03-09 14:25:00 357
原创 友元函数的应用
<br />#include <conio.h>#include <string>#include <iostream>using namespace std;class CProduct{public: CProduct(int high,int weight, string productName);private: friend ostream& operator<<(ostream& os,CProduct &product);private:
2011-03-08 23:18:00 482
原创 规定下明天的任务
<br />明天周二,有很多的空闲时间,最主要的还是要把作业完成。完成后再把电子设计的书看下。还有就是那个数据结构要看下。争取早日把它看完。C++该告一段落了。明天如果有时间就整理下C++的笔记。省的时间长了会忘掉。这里推荐几个编程的IDE。首先最好的是vc++6.0,适合新手,不用建工程,上来直接写文件就可以编译运行。太随意了。但时间长了,会发现这样会造出很多的垃圾,这个很悲剧。所以还是建工程比较好。eclipse,他开源免费,同时支持C++和JAVA,实在太好用了。CODE-BLOCKS,它也是开源的。
2011-03-07 22:11:00 325
原创 2011/3/7计划
<br />明天星期一,今天的任务有些没有完成,比如哪个C++,因为要义务劳动,没有时间看了,数字电路的作业还没有写,还有大物实验,另外随机信号有道题不会写。今天在图书馆里借了两本书,一定要把他们看完。绝不能在言而无信。
2011-03-06 22:13:00 270
原创 规定下明天需要干的几件事
<br />1.把这星期该写的作业写完,落下的专业课补上。<br />2.把c++最后一张的内容看完,并且复习下前面的知识。<br />明天做好这两件事,就OK。
2011-03-05 23:40:00 283
原创 以后开始写博,记录自己成长的点滴。
今天学了最短路,听了大牛的讲解,网上也查了资料,不过还是一知半解。明天准备继续奋斗。我现在学习上的问题是不能一心一意的做一件事,老是左顾右盼。成绩一直没有起色,很郁闷。
2011-03-05 23:38:00 234
原创 迄今为止,我见过的最完美的程序。hdu 2544
<br />/*Mail to : miyubai@gamil.comMy Blog : www.baiyun.meAuthor By : MiYuTest : 1Complier : g++ mingw32-3.4.2Program : HDU_2544Doc Name : 最短路*///#pragma warning( disable:4789 )#include <iostream>#include <fstream>#incl
2011-03-05 23:34:00 435
原创 hdu1280
<br /> #include <cstdio>#include <iostream>#include <vector>#include <queue>#include <algorithm>using namespace std;int main(void){ int n, m; vector<int >int_vec; priority_queue<int >int_pri; while(cin >> n >> m) { int_vec.clea
2011-02-27 11:24:00 520
原创 hdu1280 前m大的数
Problem Description还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大的M个数告诉她就可以了。 <br />给定一个包含N(N<=3000)个正整数的序列,每个数不超过5000,对它们两两相加得到的N*(N-1)/2个和,求出其中前M大的数(M<=1000)并按从大到小的顺序排列。 <br /> Input输入可能包含多组数据,其中每组数据包括两行: <b
2011-02-27 11:19:00 1139
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人