Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <stdexcept>
- #include <deque>
- #include <algorithm>
- #include <cmath>
- #include <functional>
- #include <vector>
- #include <set>
- #include "TestCurenja.h"
- using namespace std;
- double fun(double x)
- {
- return x*x;
- }
- void Uradi(vector<int>&a)
- {
- int b(0);
- auto it(a.begin());
- while(it!=a.end())
- {
- bool dal(true);
- int c(*it);
- int d(c%2);
- while(c!=0)
- {
- if(c%2!=d)dal=false;
- c=c/10;
- }
- if(dal==false)
- {
- a[b]=*it;
- b++;
- }
- it++;
- }
- a.resize(b);
- }
- bool DaLiJeTranzitivna(vector<vector<bool>>a)
- {
- bool jest(true);
- int i(a.size()),j(0),c(a[0].size());
- while(j<a.size())
- {
- if(c!=a[j].size())throw domain_error("Ovo nije matrica");
- if(i!=a[j].size())throw domain_error("Ovo nije matrica");
- j++;
- }
- i=0;
- j=0;
- c=0;
- while(i<a.size())
- {
- while(j<a.size())
- {
- int d(0);
- while(d<a.size())
- {
- if((a[i][j]=1)&&(a[j][d]=1))
- {
- if(a[i][j]!=a[i][d])jest=false;
- }
- d++;
- }
- j++;
- }
- i++;
- }
- return jest;
- }
- void Zamijeni(string &s, char znak)
- {
- auto it(s.begin());
- while(it!=s.end())
- {
- if(*it==' ')*it=znak;
- it++;
- }
- }
- template<typename zent,typename ako>
- zent Kontejner(zent &a,ako fun(ako))
- {
- zent b(a.size());
- auto it1(a.begin());
- auto it2(b.begin());
- while(it1!=a.end())
- {
- *it2=fun(*it1);
- it2++;
- it1++;
- }
- return b;
- }
- template<typename acc>
- acc fun(acc x)
- {
- return x*x;
- }
- int ** DinAlokacijao(int n)
- {
- int i(0);
- int **pok(nullptr);
- try
- {
- pok=new int *[n];
- while(i<n)
- {
- pok[i]=nullptr;
- pok[i]=new int[2*i+1];
- int c(i+1);
- int d(c);
- int k(0);
- if(i==0)
- {
- pok[i][k]=1;
- cout<<pok[i][k]<<endl;
- }
- if(i!=0)
- {
- while(c!=0)
- {
- pok[i][k]=c;
- cout<<pok[i][k];
- c--;
- k++;
- }
- c=2;
- while(c!=d+1)
- {
- pok[i][k]=c;
- cout<<pok[i][k];
- c++;
- }
- cout<<endl;
- }
- i++;
- }
- }
- catch(...)
- {
- cout<<"Neuspjela alokacija";
- int i(0);
- while(i<n)
- {
- delete[]pok[i];
- i++;
- }
- delete[]pok;
- }
- return pok;
- }
- int **DinoAlokacija(int n)
- {
- int **pok(nullptr);
- pok=new int *[n];
- pok[0]=new int[n*n];
- int i(1);
- int o(1);
- while(i<n)
- {
- pok[i]=pok[i-1]+o;
- int c(i+1);
- int d(c);
- int j(0);
- if(i==0)
- {
- pok[i][j]=1;
- cout<<pok[i][j]<<endl;
- }
- if(i!=0)
- {
- while(c!=0)
- {
- pok[i][j]=c;
- cout<<pok[i][j];
- c--;
- j++;
- }
- c=2;
- while(c!=d+1)
- {
- pok[i][j]=c;
- cout<<pok[i][j];
- c++;
- }
- cout<<endl;
- o=o+2;
- i++;
- }
- }
- return pok;
- }
- int main()
- {
- deque<int>a {};
- sort(a.begin(),a.end(),[](int x,int y)->bool
- {
- int prvi(0),drugi(0);
- int i(1);
- while(i<x)
- {
- if(x%i==0)prvi++;
- i++;
- }
- int j(1);
- while(j<y)
- {
- if(x%j==0)drugi++;
- j++;
- }
- if(prvi>drugi)return true;
- if((prvi==drugi)&&(prvi<drugi))return true;
- return false;
- });
- int n(5);
- auto it(DinoAlokacija(n));
- int d(0);
- while(d<n)
- {
- delete[]it[d];
- d++;
- }
- delete[]it;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement