Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main(){
- int a,b,c,ca,cc,i=0,Sc,Sa;
- cin>>a>>b;
- c=b;
- while (a!=0&&b!=0)
- {
- cin>>c;
- if (c==0)
- break;
- // ca=a;
- cc=c;
- Sa=0;
- Sc=0;
- while (a!=0)
- {
- Sa+=a%10;
- a/=10;
- }
- while (c!=0)
- {
- Sc+=c%10;
- c/=10;
- }
- if ((Sa+Sc)==b)
- {
- i++;
- // cout<<ca<<" "<<b<<" "<<cc;
- }
- a=b;
- b=cc;
- }
- cout<<i;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement