mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-09-07 12:10:40 +02:00
prawie zrobione zadania
This commit is contained in:
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad1
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad1
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad2
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad2
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad3
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad3
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad4
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad4
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad5
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad5
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad6
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad6
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad7
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad7
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad8
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad8
Executable file
Binary file not shown.
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad9
Executable file
BIN
uczelnia/2_semestr/programowanie/laby/lab10/out/zad9
Executable file
Binary file not shown.
40
uczelnia/2_semestr/programowanie/laby/lab10/zad1.cpp
Normal file
40
uczelnia/2_semestr/programowanie/laby/lab10/zad1.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <iostream>
|
||||
|
||||
class Zwierze {
|
||||
public:
|
||||
virtual void odglos() { std::cout << "..." << std::endl; }
|
||||
virtual ~Zwierze() = default;
|
||||
};
|
||||
|
||||
class Pies : public Zwierze {
|
||||
public:
|
||||
void odglos() override { std::cout << "Hau hau" << std::endl; }
|
||||
};
|
||||
|
||||
class Kot : public Zwierze {
|
||||
public:
|
||||
void odglos() override { std::cout << "Miau miau" << std::endl; }
|
||||
};
|
||||
|
||||
class Krowa : public Zwierze {
|
||||
public:
|
||||
void odglos() override { std::cout << "Muu muu" << std::endl; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
const int SIZE = 3;
|
||||
Zwierze *zwierzeta[SIZE];
|
||||
zwierzeta[0] = new Pies();
|
||||
zwierzeta[1] = new Kot();
|
||||
zwierzeta[2] = new Krowa();
|
||||
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
zwierzeta[i]->odglos();
|
||||
}
|
||||
|
||||
for (int i = 0; i < SIZE; i++) {
|
||||
delete zwierzeta[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
uczelnia/2_semestr/programowanie/laby/lab10/zad2.cpp
Normal file
20
uczelnia/2_semestr/programowanie/laby/lab10/zad2.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
|
||||
class Baza {
|
||||
public:
|
||||
void metoda() const { std::cout << "Baza" << std::endl; }
|
||||
};
|
||||
|
||||
class Pochodna : public Baza {
|
||||
public:
|
||||
void metoda() const { std::cout << "Pochodna" << std::endl; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
Pochodna p;
|
||||
Baza &ref = p;
|
||||
Baza *ptr = &p;
|
||||
p.metoda(); // pochodna
|
||||
ref.metoda(); // baza
|
||||
ptr->metoda(); // baza
|
||||
}
|
||||
17
uczelnia/2_semestr/programowanie/laby/lab10/zad3.cpp
Normal file
17
uczelnia/2_semestr/programowanie/laby/lab10/zad3.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <iostream>
|
||||
|
||||
class Baza {
|
||||
public:
|
||||
virtual void metoda() const { std::cout << "Baza" << std::endl; }
|
||||
};
|
||||
|
||||
class Pochodna : public Baza {
|
||||
public:
|
||||
void metoda() const { std::cout << "Pochodna" << std::endl; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
Pochodna p;
|
||||
Baza b = p;
|
||||
b.metoda(); // część pochodna została zgubiona
|
||||
}
|
||||
54
uczelnia/2_semestr/programowanie/laby/lab10/zad4.cpp
Normal file
54
uczelnia/2_semestr/programowanie/laby/lab10/zad4.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class Figura {
|
||||
public:
|
||||
virtual float pole() const = 0;
|
||||
virtual float obwod() const = 0;
|
||||
virtual ~Figura() = default;
|
||||
};
|
||||
|
||||
class Kolo : public Figura {
|
||||
float r;
|
||||
|
||||
public:
|
||||
Kolo(float r) : r(r) {}
|
||||
|
||||
float pole() const override { return M_PI * r * r; }
|
||||
float obwod() const override { return M_PI * 2 * r; }
|
||||
};
|
||||
|
||||
class Prostokat : public Figura {
|
||||
float a, b;
|
||||
|
||||
public:
|
||||
Prostokat(float a, float b) : a(a), b(b) {}
|
||||
|
||||
float pole() const override { return a * b; }
|
||||
float obwod() const override { return 2 * a + 2 * b; }
|
||||
};
|
||||
|
||||
class Trojkat : public Figura {
|
||||
float a, b, c, h;
|
||||
|
||||
public:
|
||||
Trojkat(float a, float b, float c, float h) : a(a), b(b), c(c), h(h) {}
|
||||
|
||||
float pole() const override { return (a * h) * 0.5; }
|
||||
float obwod() const override { return a + b + c; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
std::vector<std::unique_ptr<const Figura>> figury;
|
||||
figury.push_back(std::make_unique<Kolo>(2.0));
|
||||
figury.push_back(std::make_unique<Prostokat>(2, 3));
|
||||
figury.push_back(std::make_unique<Trojkat>(1, 2, 3, 4));
|
||||
|
||||
for (std::unique_ptr<const Figura> &element : figury) {
|
||||
std::cout << "Obwod figury to: " << element->obwod() << std::endl;
|
||||
std::cout << "Pole figury to: " << element->pole() << std::endl;
|
||||
;
|
||||
}
|
||||
}
|
||||
20
uczelnia/2_semestr/programowanie/laby/lab10/zad5.cpp
Normal file
20
uczelnia/2_semestr/programowanie/laby/lab10/zad5.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
|
||||
class Abstrakcyjna {
|
||||
public:
|
||||
virtual void f() = 0;
|
||||
virtual ~Abstrakcyjna() = default;
|
||||
};
|
||||
|
||||
class Konkretna : public Abstrakcyjna {
|
||||
public:
|
||||
void f() override { std::cout << "OK"; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
// Abstrakcyjna a; // nie kompiluje się, ponieważ a jest k
|
||||
// lasą abstrakcyjną.
|
||||
Konkretna k; // kompiluje
|
||||
Abstrakcyjna *ptr = new Konkretna(); // kompiluje
|
||||
Abstrakcyjna &ref = k; // kompiluje
|
||||
}
|
||||
32
uczelnia/2_semestr/programowanie/laby/lab10/zad6.cpp
Normal file
32
uczelnia/2_semestr/programowanie/laby/lab10/zad6.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
class Zasob {
|
||||
int *arr;
|
||||
|
||||
public:
|
||||
Zasob(size_t size) : arr(new int[size]) { std::cout << "Alokujemy arr\n"; }
|
||||
|
||||
virtual ~Zasob() { // bez tego – wyciek pamięci
|
||||
std::cout << "Destruktor virtualny\n";
|
||||
delete[] arr;
|
||||
}
|
||||
};
|
||||
|
||||
class DuzyZasob : public Zasob {
|
||||
int *arr2;
|
||||
|
||||
public:
|
||||
DuzyZasob(size_t size1, size_t size2) : Zasob(size1), arr2(new int[size2]) {
|
||||
std::cout << "Alokujemy arr2\n";
|
||||
}
|
||||
~DuzyZasob() override {
|
||||
std::cout << "Domyślny Destruktor DużegoZasobu\n";
|
||||
delete[] arr2;
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
Zasob *z = new DuzyZasob(2, 4);
|
||||
delete z;
|
||||
}
|
||||
22
uczelnia/2_semestr/programowanie/laby/lab10/zad7.cpp
Normal file
22
uczelnia/2_semestr/programowanie/laby/lab10/zad7.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
|
||||
class Ksztalt {
|
||||
public:
|
||||
virtual double pole() const = 0;
|
||||
virtual ~Ksztalt() = default;
|
||||
};
|
||||
|
||||
class Kolo : public Ksztalt {
|
||||
double r;
|
||||
|
||||
public:
|
||||
Kolo(double promien) : r(promien) {}
|
||||
double pole() const { return 3.14 * r * r; }
|
||||
};
|
||||
|
||||
void wypisz(Ksztalt &k) { std::cout << k.pole(); }
|
||||
|
||||
int main() {
|
||||
Kolo k = Kolo(2);
|
||||
wypisz(k);
|
||||
}
|
||||
31
uczelnia/2_semestr/programowanie/laby/lab10/zad8.cpp
Normal file
31
uczelnia/2_semestr/programowanie/laby/lab10/zad8.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
class Pojazd {
|
||||
public:
|
||||
virtual std::string opis() = 0;
|
||||
virtual ~Pojazd() = default;
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &os, Pojazd &p) {
|
||||
os << p.opis();
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
class Samochod : public Pojazd {
|
||||
public:
|
||||
std::string opis() override { return "To jest samochód"; }
|
||||
};
|
||||
|
||||
class Rower : public Pojazd {
|
||||
public:
|
||||
std::string opis() override { return "To jest rower"; }
|
||||
};
|
||||
|
||||
int main() {
|
||||
Samochod s;
|
||||
Rower r;
|
||||
std::cout << s << std::endl;
|
||||
std::cout << r << std::endl;
|
||||
}
|
||||
95
uczelnia/2_semestr/programowanie/laby/lab10/zad9.cpp
Normal file
95
uczelnia/2_semestr/programowanie/laby/lab10/zad9.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Adres {
|
||||
std::string ulica;
|
||||
int nr_mieszkania;
|
||||
|
||||
public:
|
||||
Adres(std::string ulica, int nr_mieszkania)
|
||||
: ulica(ulica), nr_mieszkania(nr_mieszkania) {}
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &os, Adres &adres) {
|
||||
os << adres.ulica << " mieszkania " << adres.nr_mieszkania;
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
class Pracownik {
|
||||
protected:
|
||||
std::string imie;
|
||||
float pensja;
|
||||
Adres *adres;
|
||||
|
||||
public:
|
||||
virtual float obliczWyplate() = 0;
|
||||
Pracownik(std::string imie, float pensja, Adres *adres)
|
||||
: imie(imie), pensja(pensja), adres(adres) {}
|
||||
virtual ~Pracownik() = default;
|
||||
friend std::ostream &operator<<(std::ostream &os, Pracownik &p) {
|
||||
os << p.imie << " zarabia " << p.obliczWyplate() << " i mieszka na "
|
||||
<< *(p.adres);
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
class PracownikEtatowy : public Pracownik {
|
||||
|
||||
public:
|
||||
PracownikEtatowy(std::string imie, float pensja, Adres *adres)
|
||||
: Pracownik(imie, pensja, adres) {}
|
||||
|
||||
float obliczWyplate() override { return pensja; }
|
||||
};
|
||||
|
||||
class Zleceniobiorca : public Pracownik {
|
||||
float godziny;
|
||||
|
||||
public:
|
||||
Zleceniobiorca(std::string imie, float pensja, Adres *adres, float godziny)
|
||||
: Pracownik(imie, pensja, adres), godziny(godziny) {}
|
||||
float obliczWyplate() override { return pensja * godziny; }
|
||||
};
|
||||
|
||||
class Dzial {
|
||||
std::vector<std::unique_ptr<Pracownik>> pracownicy;
|
||||
|
||||
public:
|
||||
Dzial() {};
|
||||
|
||||
void dodajPracownika(std::unique_ptr<Pracownik> pracownik) {
|
||||
pracownicy.push_back(std::move(pracownik));
|
||||
}
|
||||
|
||||
float sumaWyplat() const {
|
||||
float sum = 0;
|
||||
for (auto &pracownik : pracownicy) {
|
||||
sum += pracownik->obliczWyplate();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
void wypiszPracownikow() {
|
||||
std::cout << "=== Wszyscy pracownicy ===\n";
|
||||
for (const auto &pracownik : pracownicy) {
|
||||
std::cout << *pracownik << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main() {
|
||||
Dzial dzial = Dzial();
|
||||
dzial.dodajPracownika(std::make_unique<PracownikEtatowy>(
|
||||
"Bożena", 2500, new Adres("Żołnierska", 18)));
|
||||
|
||||
dzial.dodajPracownika(std::make_unique<Zleceniobiorca>(
|
||||
"Adam", 6700, new Adres("Wiejska", 1), 30));
|
||||
|
||||
dzial.wypiszPracownikow();
|
||||
std::cout << "Pracownicy sumarycznie zarabiają: " << dzial.sumaWyplat();
|
||||
return 0;
|
||||
}
|
||||
65
uczelnia/2_semestr/python/cuda/flake.nix
Normal file
65
uczelnia/2_semestr/python/cuda/flake.nix
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
description = "Środowisko dla ZED SDK (ZED 2i) + Python";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
config = {
|
||||
allowUnfree = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.${system}.default =
|
||||
let
|
||||
fhs = pkgs.buildFHSUserEnv {
|
||||
name = "zed-env";
|
||||
targetPkgs =
|
||||
pkgs: with pkgs; [
|
||||
glibc
|
||||
gcc-unwrapped.lib
|
||||
stdenv.cc.cc.lib
|
||||
glib
|
||||
zlib
|
||||
binutils
|
||||
pciutils
|
||||
wget
|
||||
libusb1
|
||||
|
||||
libGL
|
||||
xorg.libX11
|
||||
xorg.libXext
|
||||
|
||||
cudaPackages.cudatoolkit
|
||||
cudaPackages.cudnn
|
||||
|
||||
(python3.withPackages (
|
||||
ps: with ps; [
|
||||
pip
|
||||
numpy
|
||||
opencv4
|
||||
open3d
|
||||
]
|
||||
))
|
||||
];
|
||||
|
||||
profile = ''
|
||||
export LD_LIBRARY_PATH=/run/opengl-driver/lib:/usr/lib:/usr/lib32:$LD_LIBRARY_PATH
|
||||
export CUDA_PATH=${pkgs.cudaPackages.cudatoolkit}
|
||||
|
||||
export PIP_PREFIX=$(pwd)/.local_pip
|
||||
export PYTHONPATH=$(pwd)/.local_pip/lib/python3.11/site-packages:$PYTHONPATH
|
||||
export PATH=$(pwd)/.local_pip/bin:$PATH
|
||||
'';
|
||||
};
|
||||
in
|
||||
fhs.env;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user