Sunday, 27 May 2012
UVa 10922 2 the 9s Solution
//accepted
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
char a[1002];
int s,d,i,j,k,l,q;
bool w;
while(cin>>a)
{
l=strlen(a);
if(l==1&&a[0]=='0')return 0;
s=0;
for(i=0;i<l;i++)
s+=a[i]-48;
if(s%9==0)w=true;
else w=false;
j=1;q=0;d=s;
if(w==true)
while(d!=9&&d>9)
{q=0;
while(d!=0)
{
q+=d%10;
d=d/10;
}
d=q;
j++;
}
if(w==true)
printf("%s is a multiple of 9 and has 9-degree %d.\n",a,j);
else if(w==false)
printf("%s is not a multiple of 9.\n",a);
}
return 0;
}
Subscribe to:
Post Comments (Atom)
saeconFdiowo Dan Portwood https://marketplace.visualstudio.com/items?itemName=9ogprotuli.CONTINUE-gratuita
ReplyDeletevoilimentryt
Yagresgam_tsu_1993 Esperanza Marin https://www.evolvecontracted.com/profile/Overcooked-The-Lost-Morsel-LINK-Download-Cracked-Pc/profile
ReplyDeletefimapketic
arinci_ze-Jackson Corey Bouie Free Download
ReplyDeleteoxprocmichi
0mactpulWmagda-1988 Julie Peterman download
ReplyDeleteclick here
download
click here
secdevernei
Vconstuade-a_Manchester Caroline Fukushima https://fatfiles.net/acronis-true-image-download-nulled-licence-key-22/
ReplyDeleteAvid Pro Tools
DesignCAD 3D Max
nusumnostkom
gueidAsespi_1981 Brandy Sipes Download Free
ReplyDeleteThere
olsunveco