自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Passion

生命本没有意义,你要能给它什么意义,他就有什么意义。与其终日冥想人生有何意义,不如试用此生做点有意义的事。

  • 博客(41)
  • 资源 (1)
  • 收藏
  • 关注

转载 php 访问数据库的三种方式

3种通过php连接mysql的方法:方法一:普通方法(面向过程)$username=your_name; $userpass=your_pass; $dbhost=localhost; $dbdatabase=your_database;下面是关键步骤:1 //生成一个连接 2 $db_connect=mysql_connect($dbhost,$user

2017-09-17 15:57:55 4431

原创 TCP状态转换图

CLOSED:表示初始状态。LISTEN:该状态表示服务器端的某个SOCKET处于监听状态,可以接受连接。SYN_SENT:这个状态与SYN_RCVD遥相呼应,当客户端SOCKET执行CONNECT连接时,它首先发送SYN报文,随即进入到了SYN_SENT状态,并等待服务端的发送三次握手中的第2个报文。SYN_SENT状态表示客户端已发送SYN报文。SYN_RCVD: 该状态表示接收到

2017-08-19 15:55:08 360

原创 多进程实现并发服务器

#include #include #include #include #include #include #include #include #include #include #include "wrap.h"#define SERV_PORT 8888void wait_child(int signo){ while(waitpid(0,NULL,WNOHAN

2017-08-19 14:30:08 351

原创 常用的Linux命令

Usage: ncat [options] [hostname] [port]nc 127.0.0.1 8888    //与127.0.0.1的8888 端口建立一个socket连接netstat  -apn  |  grep  8888  //查看8888 端口的使用情况

2017-08-19 14:24:24 238

原创 判断进程是否正常退出

#include #include #include #include int main(int argc,char* argv[]){ pid_t pid,w_pid; int sta; pid = fork(); if(pid == -1){ perror("fork error"); exit(1); }else if(pid == 0){ printf("

2017-08-03 00:13:34 1171

原创 Linux 获取制定目录的文件数(递归)

#include #include #include #include #include /*获取指定文件数目(absolute path)*/int getFileNum(char* root){ DIR *dir = NULL; //打开目录 dir = opendir(root); if(dir == NULL) { perror("opendir");

2017-08-01 09:42:10 585

原创 unlink的使用

#include #include #include #include #include #include #include /*使用unlink删除一个临时文件,先打开一个文件,当关闭文件时自动删除*/int main(int argc,char* argv[]){ int fd; //打开一个文件 fd = open("tmpfile",O_CREAT|O_R

2017-07-31 23:45:01 629

原创 实现stat命令

#include #include #include #include #include #include #include #include #include int main(int argc,char* argv[]){ if(argc<2) { printf("./mystat filename\n"); exit(1); } // 文件信息结构体

2017-07-31 21:47:44 530

原创 Linux 进程

如何输出进程ID:      当需要从 C 或 C++程序中使用进程 ID 的时候,应该始终使用中定义的pid_t 类型。程序可以通过 getpid()系统调用获取自身所运行的进程的 ID,也可以通过getppid()系统调用获取父进程 ID。例如下面一段程序输出了程序运行时的进程ID 和父进程 ID。#include #include int main(){ p

2017-07-15 15:43:34 228

原创 顺序容器之间的拷贝

#include #include #include #include using namespace std;int main(){ list ilst(5,4); vector ivc(5,5); //form list to vector vector dvc(ilst.begin(),ilst.end()); for(auto i

2017-05-16 18:07:26 243

原创 剑指offer 第八题 二叉树的下一个节点

#include using namespace std;struct BinaryTreeNode{ int m_nValue; BinaryTreeNode* m_pLeft; BinaryTreeNode* m_pRight; BinaryTreeNode* m_pParent;};BinaryTreeNode* GetNext(BinaryTre

2017-05-16 09:07:47 476

原创 C++ 读取文件

#include #include #include #include using std::vector;using std::string; using std::endl; using std::ifstream; using std::cout;void ReadFileToVec(const string& fileName,vector& vec){ ifstr

2017-05-15 09:01:57 274

原创 根据二叉树的前序和中序建树

#ifndef BINARYTREE_H#define BINARYTREE_H#include struct BinaryTreeNode{ int m_nValue; BinaryTreeNode* m_nLeft; BinaryTreeNode* m_nRight;};BinaryTreeNode* CreatBinaryTre

2017-05-13 16:12:48 576

原创 剑指offer--面试题53 在排序数组中查找数字(二分)

//数字在排序数组中出现的次数#include using namespace std;int GetFirstK(const int* data,int length,int k,int start,int end);int GetLastK(const int* data,int length,int k,int start,int end);int GetNumberOfK

2017-05-12 09:10:05 482

原创 快速排序 C++

讲解建议大家直接看算法导论#include using namespace std;int Partition(int a[],int,int);void QuickSort(int a[],int,int);int main(){ int a[10] = {1,2,4,56,25,1,33,6,77,1}; int len = sizeof(a)/sizeof(int

2017-05-12 07:48:43 413

原创 剑指offer --反向输出链表与输出链表的倒数第k个元素

List.h#include "List.h"#include #include void PrintListReversingly_Iteratively(ListNode* pHead){ std::stack nodes; ListNode* pNode = pHead; while(pNode!=nullptr) { node

2017-05-11 19:33:51 271

原创 剑指offer --链表

#include #include #include using namespace std;struct Node{ int value; Node* next; Node(int v):value(v){}};void InsertList(Node *head,int key){ Node* NewNode = new Node(key)

2017-05-10 11:15:59 191

原创 vector的基本使用

#include "map"#include "iostream"#include "vector"#include "algorithm"#include "cstdio"#include "iterator"using namespace std;vector v(4);/*vector v1 vector保存类型为T的对象。默认构造函数,v1为空vector v2(v1) v2是v1的一个副

2017-05-08 14:44:30 284

原创 ubuntu 下一些简单的mysql命令

ubuntu 下一些简单的mysql命令

2017-01-04 22:37:08 259

原创 ubuntu下navicat试用到期解决办法(删除system.reg之后navicat不能运行解决办法)

ubuntu下navicat试用到期解决办法(删除system.reg之后navicat不能运行解决办法)

2017-01-04 16:48:26 13538 4

原创 数据结构学习 链表的建立

数据结构学习  链表的建立

2015-11-11 19:39:57 444

原创 poj 1182 食物链(并查集)

食物链Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 54149 Accepted: 15856Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,

2015-09-05 10:16:44 286

原创 uva 572 Oil Deposits(bfs实现)

Oil DepositsTime Limit:3000MS    Memory Limit:0KB    64bit IO Format:%lld & %lluSubmitStatusPracticeUVA 572Description The GeoSurvComp geologic survey company is responsible for detecting undergroun

2015-08-21 11:25:32 460

原创 CodeForces 550B Preparing Olympiad(dfs暴搜)

B. Preparing Olympiad time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard outputYou have n problems. You have estimated the difficulty of the

2015-08-20 18:49:33 387

原创 hdu 1431 素数回文(打表)

素数回文 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15431 Accepted Submission(s): 3442Problem Description xiaoou33对既是素数又是回文的数特别感兴趣。比如说151

2015-08-20 16:53:02 566

原创 素数打表

一种常见的素数打表的方法void init_prime(){ int i, j; for(i = 2;i <= sqrt(1000002.0); ++i) { if(!prime[i]) for(j = i * i; j < 1000002; j += i) prime[j] = 1; } j = 0; for(i = 2;i <= 1000002; ++i)

2015-08-20 09:39:13 296

原创 hdu 2544 最短路(dijkstra)

最短路Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 42811    Accepted Submission(s): 18764Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很

2015-08-18 10:03:11 345

原创 poj 3522 Slim Span(最小生成树)kruskal算法

Slim Span Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 7010 Accepted: 3711DescriptionGiven an undirected weighted graph G, you should find one of spanning trees specified as fo

2015-08-15 15:07:22 511

原创 HDU 1272 小希的迷宫(并查集)

小希的迷宫Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 35803    Accepted Submission(s): 10932Problem Description上次Gardon的迷宫城堡小希玩了很久(见P

2015-08-14 16:50:21 394

原创 hdu 1232 畅通工程(并查集)

畅通工程 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 38210 Accepted Submission(s): 20269Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条

2015-08-13 16:57:25 411

原创 zoj 2833 Friendship(并查集)

FriendshipTime Limit: 3 Seconds      Memory Limit: 32768 KB A friend is like a flower,a rose to be exact,Or maybe like a brand new gatethat never comes unlatched.A friend i

2015-08-13 16:14:11 459

原创 文章标题poj 3278 Catch That Cow(bfs实现)

Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 61611 Accepted: 19259DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catc

2015-08-11 15:59:10 320

原创 hdu 1312 Red and Black(bfs实现)

Red and Black Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 13414 Accepted Submission(s): 8306Problem Description There is a rectangular

2015-08-11 11:48:26 331

原创 dfs模板

DFS:/*该DFS 框架以2D 坐标范围为例,来体现DFS 算法的实现思想。*/#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;const int maxn=100;bool vst[maxn][maxn]; // 访问标记int map[maxn][maxn]; // 坐标范围int

2015-08-11 10:29:34 499

原创 bfs模板

#include<cstdio>#include<cstring>#include<queue>#include<algorithm>using namespace std;const int maxn=100;bool vst[maxn][maxn]; // 访问标记int dir[4][2]={0,1,0,-1,1,0,-1,0}; // 方向向量struct State // B

2015-08-11 10:28:21 344

原创 hdu 1010 Tempter of the Bone(dfs)

dfs入门的一个经典题目

2015-08-11 09:04:31 297

原创 HDU - 1312 Red and Black (dfs)

#include"iostream"#include"cstdio"#include"cstring"using namespace std;const int maxn=20+3;int m,n,visit[maxn][maxn];char pic[maxn][maxn];int sum,num;int dic[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

2015-08-08 16:26:37 258

原创 UVA - 572 Oil Deposits (dfs)

#include"iostream"#include"cstdio"#include"cstring"using namespace std;const int maxn=100+5;char pic[maxn][maxn];int visit[maxn][maxn];int m,n;void dfs(int r,int l,int num){if(rm||ln) return

2015-08-08 13:06:32 280

原创 JAVA Calendar详解

(在文章的最后,将会介绍Date类,如果有兴趣,可以直接翻到最后去阅读)究竟什么是一个 Calendar 呢?中文的翻译就是日历,那我们立刻可以想到我们生活中有阳(公)历、阴(农)历之分。它们的区别在哪呢?比如有: 月份的定义 - 阳`(公)历 一年12 个月,每个月的天数各不同;阴(农)历,每个月固定28天 每周的第一天 - 阳(公)历星期日是第一天;阴(农)历,星期一是第一天实际上,在历史上

2015-05-29 14:47:34 2232

原创 小泉的难题

小泉的难题Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^题目描述机械实验班有个同学叫小泉,有一天数学老师给小泉布置了一道个人作业,给小泉M(M输入输入包括M+1行,第一行是两个正整数M、N;M表示总共多少组数据,下面M行每行包含N个正整数,每个正整数的值不会超过10^9。(输入数据之间会用空格隔开)

2015-01-23 23:40:07 731

背包问题详解

各种背包问题详解

2015-01-28

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除