Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int Br_Cifara(int broj)
- {
- int cifra(0), brojac(0);
- while(broj!=0)
- {
- cifra=broj%10;
- brojac++;
- broj/=10;
- }
- return brojac;
- }
- int Br_ParnihCifara(int broj)
- {
- int cifra(0), brojac(0);
- while(broj!=0)
- {
- cifra=broj%10;
- if(cifra%2==0)
- {
- brojac++;
- broj/=10;
- }
- else
- {
- broj/=10;
- continue;
- }
- }
- return brojac;
- }
- int RasponCifara(int broj)
- {
- int maxi(broj%10), mini(broj%10);
- broj/=10;
- while(broj!=0)
- {
- if (broj%10<mini) mini=broj%10;
- if (broj%10>maxi) maxi=broj%10;
- broj=broj/10;
- }
- return maxi-mini;
- }
- void AnalizaBroja(int n, int &BrojCifara, int &BrojParnihCifara, int &Raspon)
- {
- BrojCifara=Br_Cifara(n);
- BrojParnihCifara=Br_ParnihCifara(n);
- Raspon=RasponCifara(n);
- }
- int main()
- {
- int n, A, B, C;
- std::cout<<"Unesite broj: ";
- std::cin>>n;
- AnalizaBroja(n, A, B, C);
- std::cout<<A<<" "<<B<<" "<<C;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement