Advertisement
STANAANDREY

a1

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