From 796b171023ca893979e13390b22d2fb7be43848d Mon Sep 17 00:00:00 2001 From: georgeyucjr Date: Mon, 1 Jan 2024 04:41:06 +0000 Subject: [PATCH] =?UTF-8?q?add=20C++/read.cpp.=20x=20=3D=20getchar=20(=20)?= =?UTF-8?q?=20=E8=BF=87=E4=BA=8E=E6=8A=BD=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- C++/read.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 C++/read.cpp diff --git a/C++/read.cpp b/C++/read.cpp new file mode 100644 index 0000000..4a1bfc7 --- /dev/null +++ b/C++/read.cpp @@ -0,0 +1,8 @@ +// ... include and using namespace +template < class T > +inline void read ( T & x ) { + char ch = getchar ( ); int f = 1; + for ( ; ch < '0' || ch > '9' ; x = getchar ( ) ) f = ch == '-' ? -1 : 1; + for ( ; ch >= '0' && ch <= '9'; x = getchar ( ) ) x = ( x << 3 ) + ( x << 1 ) + ( ch ^ 48 ); + x *= f; +} \ No newline at end of file -- Gitee