1. 程式人生 > >一個整數有幾個奇數幾個偶數字

一個整數有幾個奇數幾個偶數字

//一個整數有幾個奇數幾個偶數
#include<iostream>
#include<cmath>
using namespace std;
int s=0,t=0;
int work(long long x)
{if(x==0)
{t=0;
s=1;}
while(x!=0)
{if((x%10)%2==0)
s++;
else t++;
x/=10;
}
cout<<t<<endl<<s;
}
int main()
{long long n;
cin>>n;
work(abs(n));
return 0;
}