Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <numeric>
- #include <cmath>
- #include <vector>
- using namespace std;
- double sr;
- void pred (long long &a)
- {
- long long p(1), b = a;
- while(b)
- {
- p*=b%10;
- b/=10;
- }
- a+=p;
- }
- long long sum (long long a)
- {
- long long s(0);
- while(a)
- {
- s+=a%10;
- a/=10;
- }
- return s;
- }
- bool sortPred(long long a, long long b)
- {
- return (sum(a)<sum(b));
- }
- int main()
- {
- int n;
- cin>>n;
- vector <long long> v(n);
- for(int i = 0; i < n ; ++i)
- cin >> v[i];
- ///1
- for_each(v.begin(),v.end(),pred);
- for(int i = 0; i < n; ++i)
- cout << v[i] << ' ';
- cout << '\n';
- sort(v.begin(),v.end(),sortPred);
- for(int i = 0; i < n; ++i)
- cout << v[i] << ' ';
- cout << '\n';
- /**2if(all_of(v.begin(), v.end(), [](int i){return i % 2 == 0}))
- {
- sr = accumulate(v.begin(), v.end(), 0)/(n*1.);
- int c = count_if(v.begin(), v.end(), [](int i){return i < sr; });
- cout << "Kolichestvo elementov >" << sr <<" : " << c;
- }
- else
- cout << "Ne vse elemnti chetnie.";**/
- /**3vector <int> ras(n);
- adjacent_difference(v.begin(), v.end(), ras.begin());
- for(int i = 0; i < n; ++i)
- cout << ras[i] << ' ';
- cout << '\n';
- ras.resize(unique(ras.begin(), ras.end()) - ras.begin());
- int szr = ras.size();
- for(int i = 0; i < szr; ++i)
- cout << ras[i] << ' ';**/
- /**4vector <char> v(n);
- for(int i = 0; i < n; ++i)
- cin >> v[i];
- int k;
- cin >> k;
- while(k--)
- {
- int c;
- cin >> c;
- vector <char> v1(c);
- for(int i = 0; i < n; ++i)
- cin >> v1[i];
- cout << '\n';
- if(includes(v.begin(), v.end(), v1.begin(), v1.end())
- cout << "Yavlyaetsya podmnojestvom.\n";
- else
- cout << "Ne yavlyaetsya podmnojestvom.\n";
- }
- **/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement