关于算法源代码中头文件myhead的问题和如何在VS2010中加入自己的头文件的问题

来源:互联网 发布:0基础学编程 知乎 编辑:程序博客网 时间:2024/05/17 23:18

我的每个算法源代码的头文件都是

#include <myhead.h>

是在VS2010中设置的将自己的头文件加入了加入了系统默认头文件库,源文件为

// myhead.h#ifndef _MYHEAP_H_#define _MYHEAP_H_#include <cstdlib>#include <cctype>#include <cstring>#include <cstdio>#include <cmath>#include <algorithm>#include <vector>#include <string>#include <iostream>#include <sstream>#include <set>#include <map>#include <queue>#include <stack>#include <fstream>#include <iomanip>#include <bitset>#include <list>#include <climits>#include <ctime>#include <functional>#include <iterator>using namespace std;typedef long long LL;typedef unsigned long long ULL;//typedef __int64 _I64;          //此类型只能在C++中使用,G++不支持此类型#define CC(m,what)memset(m,what,sizeof(m))#define FOR(i,a,b)for( int i = (a) ; i < (b) ; i ++ )#define FF(i,a)for( int i = 0 ; i < (a) ; i ++ )#define FFD(i,a)for( int i = (a)-1 ; i >= 0 ; i --)#define SS(a)scanf("%d",&a)#define PARENT(a)((a)>>1)#define LL(a)((a)<<1)#define RR(a)(((a)<<1)|1)#define MID(a,b)(((a)+(b))>>1)#define SZ(a)((int)a.size())#define PP(n,m,a)puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}#define LSONl,mid,LL(rt)#define RSONmid+1,r,RR(rt)const double eps = 1e-11;const double Pi = acos(-1.0);#define readfreopen("in.txt","r",stdin)#define writefreopen("out.txt","w",stdout)#define two(x)((LL)1<<(x))#define include(a,b)(((a)&(b))==(b))template<class T> inline T countbit(T n){return n?1+countbit(n&(n-1)):0;}template<class T> inline T sqr(T a){return a*a;}template<class T> inline void checkmin(T &a,T b){if(a == -1 || a > b) a = b;}template<class T> inline void checkmax(T &a,T b){if(a < b)a = b;}const int dx[] = {-1,0,1,0};//up Right down Leftconst int dy[] = {0,1,0,-1};const int dxy[8][2]={{-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1}};const int bxy[8][2]={{-1,-2},{-1,2},{-2,1},{-2,-1},{1,2},{1,-2},{2,1},{2,-1}};#endif

这样就省去了引入各种头文件和一些常用小函数还要自己写烦恼.

那么如何引入呢?


在VS2010新建项目一个C++空项目后,单击项目.

选择项目名+属性:


在配置属性里的 VC++目录中:

选择包含目录:

点编辑后:

在输入框中输入要包含文件的路径即可:


这样就可以吧自己的头文件放进默认系统库里(具体就是用 '<' 调用头文件,而不是用双引号),如果用双引号每次就得每次都复制这个文件到工程目录下:



原创粉丝点击