Cod sursa(job #1139873)

Utilizator MagnvsDaniel Constantin Anghel Magnvs Data 11 martie 2014 16:09:34
Problema A+B Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <fstream>
#include <string>

using namespace std;

ifstream fin("adunare.in");
ofstream fout("adunare.out");

string buffer;
string::iterator buffer_it;

void read_is32nn( int &x ) { // reads next non-negative 32 bit signed integer;
    while ( *buffer_it < '0' || *buffer_it > '9' ) {
        ++buffer_it;
    }
    x = 0;
    while ( *buffer_it >= '0' && *buffer_it <= '9' ) {
        x = x * 10 + *buffer_it - '0';
        ++buffer_it;
    }
}

int main(  ) {
    getline(fin, buffer, char(0));
    buffer_it = buffer.begin();

    int a, b;
    read_is32nn(a); read_is32nn(b);
    fout << a + b << "\n";

    return 0;
}