Advertisement
STANAANDREY

PBc

Nov 28th, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5.  
  6. int main(){
  7.  
  8.   int a,b,c,ca,cc,i=0,Sc,Sa;
  9.  
  10.   cin>>a>>b;
  11.   c=b;
  12.   while (a!=0&&b!=0)
  13.   {
  14.       cin>>c;
  15.        if (c==0)
  16.         break;
  17.      // ca=a;
  18.       cc=c;
  19.       Sa=0;
  20.       Sc=0;
  21.       while (a!=0)
  22.       {
  23.           Sa+=a%10;
  24.           a/=10;
  25.       }
  26.  
  27.       while (c!=0)
  28.       {
  29.           Sc+=c%10;
  30.           c/=10;
  31.       }
  32.  
  33.       if ((Sa+Sc)==b)
  34.       {
  35.           i++;
  36.           // cout<<ca<<" "<<b<<" "<<cc;
  37.       }
  38.       a=b;
  39.       b=cc;
  40.  
  41.   }
  42.     cout<<i;
  43.  
  44.    return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement