Editorial for Цифри в текст


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.
by: maya

Тестовете можете да видите тук.

Примерно решение на C++:

#include <iostream>
using namespace std;
int main ()
{
    char a;
    int i,brc=0,s=0;
    for(i=1; i<=7; i++)
    {
        a=cin.get();
        if(a>='0' && a<='9')
        {
            s=s+a-'0';
            brc++;
        }
    }
    if(brc==0)
       cout<<-1<<endl;
    else
       cout<<s<<endl;
    return 0;
}

Comments

There are no comments at the moment.