關於算法源代碼中頭文件myhead的問題和如何在VS2010中加入自己的頭文件的問題

我的每個算法源代碼的頭文件都是

#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 LSON			l,mid,LL(rt)
#define RSON			mid+1,r,RR(rt)
const double eps = 1e-11;
const double Pi = acos(-1.0);
#define read			freopen("in.txt","r",stdin)
#define write			freopen("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 Left
const 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++目錄中:

選擇包含目錄:

點編輯後:

在輸入框中輸入要包含文件的路徑即可:


這樣就可以吧自己的頭文件放進默認系統庫裏(具體就是用 '<' 調用頭文件,而不是用雙引號),如果用雙引號每次就得每次都複製這個文件到工程目錄下:



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章