Cod sursa(job #1779653)

Utilizator antracodRadu Teodor antracod Data 15 octombrie 2016 15:29:47
Problema A+B Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <iostream>
#include <fstream>

using namespace std;

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

string buffer;
string::iterator buffer_it;

int read_int(int &x) {
    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;
    }
    return x;
}

int main( ) {
    getline(fin, buffer, (char)0);
    buffer_it = buffer.begin();
    int x, y;
    x = read_int(x);
    y = read_int(y);
    fout << x+y << "\n";

    return 0;
}