UVA Problem 10922 (The 9s) Solution

Problem Solving, UVa

#include <bits/stdc++.h>

using namespace std;

char in[1002];

int main()

{

    int j,i,count,sum,totat,digit,deg,l,q,d;

   

    bool flag;

   

    while(1)

    {

        flag=true;

   

        sum=0;

   

    l=strlen(gets(in));

   

    if(l==1 && in[0]=='0')return 0;

   

    for(i=0;i<l;i++)

   

    sum+=in[i]-'0';

   

    if(sum%9==0) flag=true;

   

    else

   

    flag=false;

     

        count=1;q=0;d=sum;



        if(flag==true)

        while(d!=9 and d>9)

        {

            while(d!=0)

            {

             q+=d%10;

             d=d/10;

            }

            d=q;



        count++;

        }



        if(flag==true)

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

        else if(flag==false)

        printf("%s is not a multiple of 9.\n",in);



    }



    return 0;

}

 

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...