Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a, b, cnt1=0, cnt2=0, c;
- bool p=1, k=1;
- cout<<"a="; cin>>a;
- cout<<"b="; cin>>b;
- if(a%2==0)
- p=1;
- else
- p=0;
- if(b%2==0)
- k=1;
- else
- k=0;
- if(p==k)
- {
- while(a)
- {
- c=a%10;
- if(c%2==0)
- cnt1++;
- a/=10;
- }
- while(b)
- {
- c=b%10;
- if(c%2==0)
- cnt1++;
- b/=10;
- }
- }
- if(cnt1)
- cout<<cnt1<<"\n";
- if(p!=k)
- {
- while(a)
- {
- c=a%10;
- if(c%2==1)
- cnt2++;
- a/=10;
- }
- while(b)
- {
- c=b%10;
- if(c%2==1)
- cnt2++;
- b/=10;
- }
- }
- if(cnt2)
- cout<<cnt2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment