Cod sursa(job #1928857)

Utilizator rublictimeeaRublic Timeea rublictimeea Data 16 martie 2017 20:15:57
Problema A+B Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 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()
{
    ifstream fin ("suma.in");
    ofstream fout ("suma.out");
    char c;
    int x,r,r2=0;
    scanf ("%c", &c);
    r = 0;
    while (isdigit(c))
    {
        x=c;
        r=r*10+x-'0';
        scanf ("%c", &c);
    }
    scanf ("%c", &c);
    while (isdigit(c))
    {
        x=c;
        r2=r2*10+x-'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;
}