fast io in c++ code example
Example 1: fast io
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
return 0;
}
Example 2: fast io c++
#include <bits/stdc++.h>
using namespace std;
template <typename T> void in(T& x)
{
x = 0; T f = 1;
char ch = getchar();
while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
x *= f;
}
template<typename T> void out(T n)
{
bool neg = 0;
if (n < 0)
n *= -1, neg = 1;
char snum[20];
int i = 0;
do
{
snum[i++] = n % 10 + '0';
n /= 10;
}
while (n);
--i;
if (neg)
putchar('-');
while (i >= 0)
putchar(snum[i--]);
putchar('\n');
}
main() {
int n;
in(n);
out(n);
}
Example 3: fast io c++
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
Example 4: fastinput c++
void fastInput(int &x)
{
bool neg=false;
register int c;
x =0;
c=getchar();
if(c=='-')
{
neg = true;
c=getchar();
}
for(;(c>47 && c<58);c=getchar())
x = (x<<1) + (x<<3) +c -48;
if(neg)
x *=-1;
}
Example 5: fast io c++
fastio.pythonanywhere.com