Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //02.07.2019.
- #include <iostream>
- using namespace std;
- template<typename Tip>
- int countUnique(Tip* polje, int n)
- {
- int unique = 0;
- for (int i = 0; i < n; i++)
- {
- int brojac = 0;
- for (int j = 0; j < n; j++)
- {
- if (polje[i] == polje[j])
- {
- brojac++;
- }
- }
- if (brojac == 1)
- {
- unique++;
- }
- }
- return unique;
- }
- class Acceleration
- {
- int x, y;
- double z;
- public:
- Acceleration() : x(0), y(0), z(0) {}
- Acceleration(int a, int b, double c) : x(a), y(b), z(c){}
- friend bool operator== (const Acceleration& ref1, const Acceleration& ref2)
- {
- return ref1.x == ref2.x && ref1.y == ref2.y && ref1.z == ref2.z;
- }
- };
- class Iznimka : public runtime_error
- {
- double energyPerOps;
- public:
- Iznimka(double energy) : energyPerOps(energy), runtime_error("ERROR") {}
- int getEnergyPerOps() const
- {
- return energyPerOps;
- }
- };
- class Processor
- {
- int mCoreCount;
- int mBaseOpsPerSecond;
- int mCurrentOpsPerSecond;
- int mRestore;
- public:
- Processor(int core, int base, int current) : mCoreCount(core), mBaseOpsPerSecond(base), mCurrentOpsPerSecond(current), mRestore(mBaseOpsPerSecond){}
- Processor(int core, int base) : mCoreCount(core), mBaseOpsPerSecond(base), mCurrentOpsPerSecond(base), mRestore(mBaseOpsPerSecond) {}
- void boost()
- {
- mBaseOpsPerSecond += 0.1;
- }
- void restore()
- {
- mBaseOpsPerSecond = mRestore;
- }
- double dimesion(int redak, int stupac, int opsPerPixel)
- {
- int pixeli = redak * stupac;
- int ops = pixeli * opsPerPixel;
- return (ops / mBaseOpsPerSecond) / 60;
- }
- int getBaseOps () const
- {
- return mBaseOpsPerSecond;
- }
- void setBaseOps(int vrijed)
- {
- mBaseOpsPerSecond = vrijed;
- }
- };
- double usteda(Processor proc, int* polje, int vel)
- {
- double vrijeme = 0;
- double vrijeme2 = 0;
- for (int i = 0; i < vel; i++)
- {
- vrijeme += polje [i] / proc.getBaseOps() ;
- }
- proc.boost();
- for (int i = 0; i < vel; i++)
- {
- vrijeme2 += polje[i] / proc.getBaseOps();
- }
- return (vrijeme - vrijeme2) / 60;
- }
- void demo()
- {
- Processor fryzen5(6, 24);
- fryzen5.boost();
- fryzen5.restore();
- }
- class EnergyAwareProcessor : public Processor
- {
- double eneryPerOps, limit;
- public:
- EnergyAwareProcessor(double energy, double lim, int core, int base, int current) : eneryPerOps(energy), limit(lim), Processor(core, base, current){}
- bool provjera()
- {
- return eneryPerOps <= limit;
- }
- double dimesion(int redak, int stupac, int opsPerPixel)
- {
- if (!provjera())
- {
- setBaseOps((3 / 4)*getBaseOps());
- }
- int pixeli = redak * stupac;
- int ops = pixeli * opsPerPixel;
- return (ops / getBaseOps()) / 60;
- }
- };
- int main()
- {
- int data[] = { 1, 2, 3, 3, 3, 4 };
- cout << countUnique(data, 6) << endl;
- Acceleration accelerations[] = { Acceleration(), Acceleration (0, 0, 9.81), Acceleration(0, 0, 9.81)};
- cout << countUnique(accelerations, 3) << endl;
- int polje[] = { 1, 2, 3, 3, 4, 5 };
- cout << countUnique(polje, 6) << endl;
- int n;
- cin >> n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement