标签:
#include<cstdio> int Sum(int n) { int sum=0; while(n!=0) { sum+=n%10; n/=10; } return sum; } void Cal(int a,int b) { while(a!=b) { if(a<b) { a+=Sum(a); } else { b+=Sum(b); } } printf("%d\n",a); } int main() { int n; int count=1; while(~scanf("%d",&n)&&n) { if(count>1) printf("\n"); printf("Case #%d\n",count++); int nn=Sum(n); if(nn%9==0) { printf("first meets river 9 at "); Cal(9,n); } else if(nn%3==0) { printf("first meets river 3 at "); Cal(3,n); } else { printf("first meets river 1 at "); Cal(1,n); } } }
标签:
原文地址:http://www.cnblogs.com/sxy-798013203/p/5689918.html