Subscribe Us

Responsive Advertisement

Advertisement

URI Online Judge | 1987 Divisibility by 3 solution in cpp

 

uri 1987 solution in cpp

#include<bits/stdc++.h>

using namespace std;

main()

{

    int n,i,c;

    string s;

    while(cin>>n>>s)

    {

        c=0;

        for(i=0;i<s.size();i++)

        {

            if(s[i]>='0'&&s[i]<='9')

            {

                c+=s[i]-'0';


            }

        }

        if(c%3==0)

        {

            cout<<c<<" sim"<<endl;

        }

        else

        {

            cout<<c<<" nao"<<endl;

        }

    }


    return 0;

}


Post a Comment

0 Comments