赞
踩
当你不知道万能头写C++代码时
#include <iostream> #include <cstdio> #include <fstream> #include <algorithm> #include <cmath> #include <deque> #include <vector> #include <queue> #include <string> #include <cstring> #include <map> #include <stack> #include <set> using namespace std; int main() { return 0; }
然后 拥有了万能头之后的你写代码时
#include<bits/stdc++.h>
using namespace std;
int main()
{
return 0;
}
怎么说呢,哪个美观,简便,一眼就看得出。
因为#include<bits/stdc++.h>包含了目前c++所包含的所有头文件
<bits/stdc++.h>的源代码
// C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2014 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 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif
当然C++这个万能头文件也有他的缺点,它会降低编译速度(为何会降低编译速度,我还不能知道,等到之后学编译原理再来填坑吧)。
当然,私下自己想好好学习C++就不要去使用了,对你的自主学习一点都没有好处。(实力嘲讽我自己)
笔试平台可以使用,方便,VS中并不支持,一般G++ 4.4以上就支持这个头文件了,c++11支持这个。
一些小伙伴在安装了VS后(我安装的是2019),新建项目,
然后输入了一下代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout << "hello world"<< endl;
return 0;
}
震惊!!竟然报错了!
很多轻量级IDE cb devcpp 包括vscode都支持万能头文件,但是vs没有,但是敲代码的时候敲一个万能头文件岂不是省下很多事
别慌,这么好用的万能头,在VS里怎么可以不用呢!
在捣鼓了半天,借鉴了多为大佬们的博客后,我成功让自己的VS可以正常使用万能头文件啦。
VC->Tools->MSVC->14.24.28314(此文件夹名每个人会有不同)->include
然后把含有<bits/stdc++.h>的源代码的.h文件复制到bits文件夹中
(当然,如果你曾经安装过MinGW或者说什么其他编译器,dev cb等 是可以去安装的文件夹中找到bits文件夹的,然后复制即可)
然后 重启vs 之后 你再输入刚刚那段代码,就可以用啦!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。