Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int main ()
- {
- vector<int> v= {12,2,6,55,2,9,7,2,14,8};
- cout<<"Najveci element: "<<*(max_element(v.begin(),v.end()))<<endl;
- cout<<"Najmanji element se ponavlja "<<count(v.begin(),v.end(),*(min_element(v.begin(),v.end())))<<" puta."<<endl;
- cout<<"Brojeva koji su stepeni dvojke ima: "<<count_if(v.begin(),v.end(),[](int n)
- {
- for (int i=0; i<20; i++)
- {
- if (pow(2,i)==n) return true;
- }
- return false;
- })<<"."<<endl;
- cout<<"Element sa najmanjom sumom cifara je "<<*(min_element(v.begin(),v.end(),[] (int a, int b)
- {
- int suma1=0,suma2=0;
- while (a!=0)
- {
- suma1+=a%10;
- a/=10;
- }
- while (b!=0)
- {
- suma2+=b%10;
- b/=10;
- }
- if (suma1<suma2) return true;
- return false;
- }))<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement