1. 程式人生 > >萬能標頭檔案#include"bits/stdc++.h"

萬能標頭檔案#include"bits/stdc++.h"

最近在打cf時賽後翻閱別人的程式碼總是會發現一個陌生而奇怪的標頭檔案#include<bits/stdc++.h>

奇怪之處就在於基本上所有的程式碼只要用了這個標頭檔案就不再寫其他標頭檔案了。

百度過後彷彿打開了新世界的大門,標頭檔案居然還可以這樣用!!!

#include<bits/stdc++.h>包含了目前c++所包含的所有標頭檔案!!!!

從此開啟開掛般的人生啊!!

現在再看下面這一堆亂七八糟的標頭檔案顯得莫名的冗雜:

複製程式碼
 1 #include <iostream> 
 2 #include <cstdio> 
 3 #include <fstream> 
 4
#include <algorithm> 5 #include <cmath> 6 #include <deque> 7 #include <vector> 8 #include <queue> 9 #include <string> 10 #include <cstring> 11 #include <map> 12 #include <stack> 13 #include <set> 14 using namespace std; 15 16
int main(){ 17 18 return 0; 19 }
複製程式碼

再看我們開掛以後:

複製程式碼
1 #include<bits/stdc++.h>
2 using namespace std;
3 
4 int main(){
5     
6     return 0;
7 }
複製程式碼

簡潔明瞭啊是不是 一眼望穿啊是不是 心動了是不是 大腦充血了是不是 幸福昏厥了是不是 再也不用擔心CE了是不是!!!

談一下朋友們擔心的相容性問題,一早起來跑了幾個oj親測相容性還是蠻強的,看到去年的介紹部落格表示hdu不支援不過現在親測已經支援了,請在hdu肆無忌憚的開掛吧!!

不過...去年不支援的poj如今也還是不支援:

p.s.

Language要選擇G++

當然國外的主流oj,臺灣的oj,Codeforces和Topcoder這些去年就已經支援#include<bits/stdc++.h>的oj如今也依舊支援。

當然我也是資辭滴( ̄︶ ̄)↗

此處附上原始碼

// 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

轉載出處:https://www.cnblogs.com/Kiven5197/p/5745589.html