- 博客(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
4524
原创 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
403
原创 多进程实现并发服务器
#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
381
原创 常用的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
278
原创 判断进程是否正常退出
#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
1220
原创 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
662
原创 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
689
原创 实现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
569
原创 Linux 进程
如何输出进程ID: 当需要从 C 或 C++程序中使用进程 ID 的时候,应该始终使用中定义的pid_t 类型。程序可以通过 getpid()系统调用获取自身所运行的进程的 ID,也可以通过getppid()系统调用获取父进程 ID。例如下面一段程序输出了程序运行时的进程ID 和父进程 ID。#include #include int main(){ p
2017-07-15 15:43:34
256
原创 顺序容器之间的拷贝
#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
276
原创 剑指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
497
原创 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
313
原创 根据二叉树的前序和中序建树
#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
619
原创 剑指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
518
原创 快速排序 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
442
原创 剑指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
298
原创 剑指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
224
原创 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
338
原创 ubuntu下navicat试用到期解决办法(删除system.reg之后navicat不能运行解决办法)
ubuntu下navicat试用到期解决办法(删除system.reg之后navicat不能运行解决办法)
2017-01-04 16:48:26
13777
1
原创 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
310
原创 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
488
原创 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
410
原创 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
595
原创 素数打表
一种常见的素数打表的方法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
320
原创 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
369
原创 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
538
原创 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
420
原创 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
438
原创 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
494
原创 文章标题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
354
原创 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
356
原创 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
539
原创 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
387
原创 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
289
原创 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
308
原创 JAVA Calendar详解
(在文章的最后,将会介绍Date类,如果有兴趣,可以直接翻到最后去阅读)究竟什么是一个 Calendar 呢?中文的翻译就是日历,那我们立刻可以想到我们生活中有阳(公)历、阴(农)历之分。它们的区别在哪呢?比如有: 月份的定义 - 阳`(公)历 一年12 个月,每个月的天数各不同;阴(农)历,每个月固定28天 每周的第一天 - 阳(公)历星期日是第一天;阴(农)历,星期一是第一天实际上,在历史上
2015-05-29 14:47:34
2291
原创 小泉的难题
小泉的难题Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^题目描述机械实验班有个同学叫小泉,有一天数学老师给小泉布置了一道个人作业,给小泉M(M输入输入包括M+1行,第一行是两个正整数M、N;M表示总共多少组数据,下面M行每行包含N个正整数,每个正整数的值不会超过10^9。(输入数据之间会用空格隔开)
2015-01-23 23:40:07
778
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人