Cottarelle in classe

#include <cstdio>

int readInt()
{
    int res = 0;
    char ch = 0;
    while(ch < '0') ch = getchar_unlocked();
    for(; ch >= '0'; ch = getchar_unlocked()) res = res * 10 + ch - '0';
    return res;
}

void writeInt(int v)
{
    char buf[14];
    int p = 0;
    if(v == 0) buf[p++] = 0;
    for(; v; v /= 10) buf[p++] = v % 10;
    while(p--) putchar_unlocked(buf[p] + '0');
}

int main()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    
    int N = readInt();
    writeInt(N);
}

Occhio che tutte le funzioni postate finora non gestiscono i numeri negativi

1 Mi Piace