论头文件

P1001 A+B Problem

Auto_Accepted @ 2022-12-21 16:51:57

RT,教以下代码能过:

#include <iostream>//注意这里!!!!
using namespace std;
int a , b;
main(){
    scanf("%d%d" , &a , &b);
    printf("%d" , a + b);
}

尤其注意头文件


by sunyizhe @ 2022-12-21 17:00:16

竟然真的可以A

这是我电脑上的 iostream

// Standard iostream objects -*- C++ -*-

// Copyright (C) 1997-2014 Free Software Foundation, Inc.
//
// This [file](/user/754294) 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 [file](/user/754294)s COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @[file](/user/754294) include/iostream
 *  This is a Standard C++ Library header.
 */

//
// ISO C++ 14882: 27.3  Standard iostream objects
//

#ifndef _GLIBCXX_IOSTREAM
#define _GLIBCXX_IOSTREAM 1

#pragma GCC system_header

#include <bits/c++config.h>
#include <ostream>
#include <istream>

[name](/user/20787)space std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION

  /**
   *  @[name](/user/20787) Standard Stream Objects
   *
   *  The &lt;iostream&gt; header declares the eight <em>standard stream
   *  objects</em>.  For other declarations, see
   *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/io.html
   *  and the @[link](/user/20011) iosfwd I/O forward declarations @end[link](/user/20011)
   *
   *  They are required by default to cooperate with the global C
   *  library's @c FILE streams, and to be available during program
   *  startup and termination. For more information, see the section of the
   *  manual [link](/user/20011)ed to above.
  */
  //@{
  extern istream cin;       /// Linked to standard input
  extern ostream cout;      /// Linked to standard output
  extern ostream cerr;      /// Linked to standard error (unbuffered)
  extern ostream clog;      /// Linked to standard error (buffered)

#ifdef _GLIBCXX_USE_WCHAR_T
  extern wistream wcin;     /// Linked to standard input
  extern wostream wcout;    /// Linked to standard output
  extern wostream wcerr;    /// Linked to standard error (unbuffered)
  extern wostream wclog;    /// Linked to standard error (buffered)
#endif
  //@}

  // For construction of [file](/user/754294)buffers for cout, cin, cerr, clog et. al.
  static ios_base::Init __ioinit;

_GLIBCXX_END_NAMESPACE_VERSION
} // [name](/user/20787)space

#endif /* _GLIBCXX_IOSTREAM */

竟然没有 scanfprintf


by HeCao2008 @ 2022-12-21 17:00:40

@sunrise1024 哦,本人不清楚,那么既然都能兼容不就得了吗


by SDqwq @ 2022-12-21 17:21:57

@xuyiluo2 你交到cf上应该就会CE


by SDqwq @ 2022-12-21 17:22:30

@xuyiluo2 并不兼容,只不过是某些编译器自动进行了一些操作


by PRIMITIVE_LIGHTS @ 2022-12-25 17:55:21

@SDqwq 不会CE,试过一次


by MrJC_Pandingding @ 2022-12-25 19:54:10

在iostream头文件中include了cstdio,有的评测机就自动包含了cstdio,你试试只包含iostream,写freopen

by Whykkkkkkk @ 2023-01-16 19:29:30

是int main()


by Sprague_Garundy @ 2023-01-23 15:59:10

@xuyiluo2 所以就是因为 iostream 里包含了 cstdio 吧。


by Abu_Dumbledore @ 2023-02-02 10:25:54

万能头文件:

#include<bits/stdc++.h>
using namespace std;

by COKENOTFOUND @ 2023-02-07 18:50:53

好像老版本是不兼容的


上一页 | 下一页