Cod sursa(job #1928864)

Utilizator rublictimeeaRublic Timeea rublictimeea Data 16 martie 2017 20:21:54
Problema A+B Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <iostream>
#include <fstream>
#include <cmath>

using namespace std;

bool isdigit(char c){
    if (c-48>9 || c-48<0)
        return 0;
return 1;
}

int nrcif (int n){
    int z=0;
    while (n){
        z++;
        n=n/10;
    }
return z;
}

int main()
{
    freopen ("adunare.in", "r", stdin);
    freopen ("adunare.out", "w", stdout);
    char c;
    int x,r,r2=0;
    scanf ("%c", &c);
    r = 0;
    while (isdigit(c))
    {
        r=r*10+c-'0';
        scanf ("%c", &c);
    }
    scanf ("%c", &c);
    while (isdigit(c))
    {
        r2=r2*10+c-'0';
        scanf ("%c", &c);
    }
    int n=r+r2;
    int i, z, cif;
    z=nrcif(n);
    char kk;
    for (i=1;i<=z;i++){
        cif=(n/(int)pow(10,z-i))%10;
        kk=cif+'0';
        cout<<kk;
    }
    return 0;
}