About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

রবিবার, ১০ আগস্ট, ২০১৪

UVA :10922 - 2 the 9s


http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=24&problem=1863&mosmsg=Submission+received+with+ID+14017231


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;


int main()
{


    char ss[1005];
    int i,l,sum,k,s;
    while(scanf("%s",ss)==1)
    {
        l=strlen(ss);
        if(l==1&&ss[0]=='0')
        {
            break;
        }
        sum=0;k=0;
        for(i=0;i<l;i++)
        {
            sum+=(ss[i]-'0');
        }
        if(sum%9!=0)
        {
            printf("%s is not a multiple of 9.\n",ss);
        }

        else{
            k++;
           while(sum>9)
           {
               s=0;
               while(sum)
               {
                   s+=sum%10;
                   sum/=10;
               }
               sum=s;
               k++;
           }

              printf("%s is a multiple of 9 and has 9-degree %d.\n",ss,k);
        }

    }
    return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন