Code:
標風:
#include <cstdio>
#include <iostream>
inline void read ( int & f) {
f = 0 ; int flag = 1 ; char c = getchar ( ) ;
while ( ! isdigit ( c) ) { if ( c == '-' ) flag = - 1 ; c = getchar ( ) ; }
while ( isdigit ( c) ) f = ( f<< 1 ) + ( f<< 3 ) + c - 48 , c = getchar ( ) ;
}
void write ( int x) {
if ( x > 9 ) write ( x / 10 ) ; putchar ( x % 10 + 48 ) ; return ;
}
void write_ ( int x) {
if ( x < 0 ) putchar ( '-' ) , x = - x;
write ( x) ; putchar ( ' ' ) ;
}
void writeln ( int x) {
if ( x < 0 ) putchar ( '-' ) , x = - x;
write ( x) ; putchar ( '\n' ) ;
}
註釋版:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
inline void read ( int & f) {
f= 0 ; int flag= 1 ; char c= getchar ( ) ;
while ( ! isdigit ( c) ) { if ( c== '-' ) flag= - 1 ; c= getchar ( ) ; }
while ( isdigit ( c) ) { f= ( f<< 3 ) + ( f<< 1 ) + c- 48 ; c= getchar ( ) ; }
f* = flag; return ;
}
void write ( int x) {
if ( x> 9 ) write ( x/ 10 ) ; putchar ( x% 10 + 48 ) ; return ;
}
void write_ ( int x) {
if ( x< 0 ) putchar ( '-' ) , x= - x;
write ( x) ; putchar ( ' ' ) ; return ;
}
void writeln ( int x) {
if ( x< 0 ) putchar ( '-' ) , x= - x;
write ( x) ; putchar ( '\n' ) ; return ;
}
int main ( ) {
int x; read ( x) ;
write_ ( x) ; writeln ( x) ;
write_ ( x) ; write ( x)
}
無註釋版
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
inline void read ( int & f) {
f= 0 ; int flag= 1 ; char c= getchar ( ) ;
while ( ! isdigit ( c) ) { if ( c== '-' ) flag= - 1 ; c= getchar ( ) ; }
while ( isdigit ( c) ) { f= ( f<< 3 ) + ( f<< 1 ) + c- 48 ; c= getchar ( ) ; }
f* = flag; return ;
}
void write ( int x) {
if ( x> 9 ) write ( x/ 10 ) ; putchar ( x% 10 + 48 ) ; return ;
}
void write_ ( int x) {
if ( x< 0 ) putchar ( '-' ) , x= - x;
write ( x) ; putchar ( ' ' ) ; return ;
}
void writeln ( int x) {
if ( x< 0 ) putchar ( '-' ) , x= - x;
write ( x) ; putchar ( '\n' ) ; return ;
}
int main ( ) {
int x; read ( x) ;
write_ ( x) ; writeln ( x) ;
write_ ( x) ; write ( x)
}
fread & fwrite版:
#include <cstdio>
#include <iostream>
using namespace std;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ?EOF : *p1++)
char buf[ 1 << 21 ] , * p1 = buf, * p2 = buf, buff[ 1 << 21 ] , a[ 20 ] ;
int p_, p__ = - 1 ;
inline void read ( int & f) {
f = 0 ; int flag = 1 ; char c = getchar ( ) ;
while ( ! isdigit ( c) ) { if ( c == '-' ) flag = - 1 ; c = getchar ( ) ; }
while ( isdigit ( c) ) f = ( f<< 1 ) + ( f<< 3 ) + c - 48 , c = getchar ( ) ;
}
inline void flush ( ) {
fwrite ( buff, 1 , p__+ 1 , stdout ) , p__ = - 1 ;
}
inline void write ( int x) {
if ( p__ > ( 1 << 20 ) ) flush ( ) ;
if ( x < 0 ) buff[ ++ p__] = 45 , x = - x;
do {
a[ ++ p_] = x % 10 + 48 ;
} while ( x/ = 10 ) ;
do {
buff[ ++ p__] = a[ p_] ;
} while ( -- p_) ;
}
inline void writeln ( int x) {
write ( x) ;
buff[ ++ p__] = '\n' ;
}
int main ( ) {
freopen ( "1.txt" , "r" , stdin ) ;
freopen ( "2.txt" , "w" , stdout ) ;
int n;
read ( n) ;
writeln ( n) ;
write ( n) ;
if ( p__ != - 1 ) flush ( ) ;
}