最近在看acm的ac代码时,发现大神用的头文件只有一行,而自己有时写头文件都要写老半天。在网上查了很多资料,终于也可以像大佬一样只写一行头文件,现在写代码都感觉很轻松。
其实在codeforces已经有过说明,那我就简单翻一下吧。
- 如果安装了MinGW的直接在文件夹里面找到bits这个文件夹,把里面内容复制粘贴到vs的头文件库(一般是在c盘的安装目录)里面。
- 如果没有安装MinGW,那么自己在vs的include文件夹里面新建一个bits文件夹,里面新建一个名叫stdc++.h的头文件,里面写你常用的头文件,(我添加的位置就在C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\bits),这里我搬运一下stdc++.h源文件:
stdc++.h
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCH

通过学习大神的编程习惯,了解到可以使用#include <bits/stdc++.h>这一行头文件来替代多个单独的头文件导入。此方法适用于安装了MinGW的环境,只需将bits文件夹内容复制到VS头文件库。若未安装MinGW,可手动在VS的include/bits创建stdc++.h文件,包含常用头文件。
最低0.47元/天 解锁文章
546

被折叠的 条评论
为什么被折叠?



