mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-09-07 12:10:40 +02:00
notatki
This commit is contained in:
5
uczelnia/2_semestr/programowanie/laby/lab2/zad1.cpp
Normal file
5
uczelnia/2_semestr/programowanie/laby/lab2/zad1.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
int a = 10; // 10
|
||||||
|
double b = a; // 10
|
||||||
|
int c = 3.8; // 3
|
||||||
|
bool d = c; // true
|
||||||
|
char e = 'K'; // K
|
||||||
9
uczelnia/2_semestr/programowanie/laby/lab2/zad2.cpp
Normal file
9
uczelnia/2_semestr/programowanie/laby/lab2/zad2.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << 5 / 2 << '\n'; // 2
|
||||||
|
std::cout << 5 / 2.0 << '\n'; // 2.5
|
||||||
|
int x = 7;
|
||||||
|
double y = 2;
|
||||||
|
std::cout << x / y << '\n'; // 3
|
||||||
|
}
|
||||||
6
uczelnia/2_semestr/programowanie/laby/lab2/zad3.cpp
Normal file
6
uczelnia/2_semestr/programowanie/laby/lab2/zad3.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
int main() {
|
||||||
|
int a{5};
|
||||||
|
double b{5};
|
||||||
|
// int c{3.14}; nie skompiluje się przez niepoprawny typ danych rzutowany
|
||||||
|
int d = 3.14;
|
||||||
|
}
|
||||||
9
uczelnia/2_semestr/programowanie/laby/lab2/zad4.cpp
Normal file
9
uczelnia/2_semestr/programowanie/laby/lab2/zad4.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
bool czyParzysta(int n);
|
||||||
|
int poleProstokata(int a, int b);
|
||||||
|
double srednia(int a, int b, int c);
|
||||||
|
|
||||||
|
bool czyParzysta(int n) { return n % 2 == 0; }
|
||||||
|
|
||||||
|
int poleProstokata(int a, int b) { return a * b; }
|
||||||
|
|
||||||
|
double srednia(int a, int b, int c) { return (double)(a + b + c) / 3; }
|
||||||
15
uczelnia/2_semestr/programowanie/laby/lab2/zad5.cpp
Normal file
15
uczelnia/2_semestr/programowanie/laby/lab2/zad5.cpp
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void podwoj1(int x) { x *= 2; }
|
||||||
|
void podwoj2(int &x) { x *= 2; }
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a = 5;
|
||||||
|
cout << a << endl;
|
||||||
|
podwoj1(a); // nie zmieni wartości poza funkcją
|
||||||
|
cout << "a po podwojeniu kopią: " << a << endl;
|
||||||
|
podwoj2(a); // zmieni wartość poza funkcją
|
||||||
|
cout << "a po podwojeniu referencją: " << a << endl;
|
||||||
|
}
|
||||||
17
uczelnia/2_semestr/programowanie/laby/lab2/zad6.cpp
Normal file
17
uczelnia/2_semestr/programowanie/laby/lab2/zad6.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void rysujLinie(char znak = '*', int ile = 5) {
|
||||||
|
for (int i = 0; i < ile; i++) {
|
||||||
|
cout << znak;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cout << "bez argumentów:" << endl;
|
||||||
|
rysujLinie();
|
||||||
|
cout << endl << "z jednym argumentem: " << endl;
|
||||||
|
rysujLinie('-');
|
||||||
|
cout << endl << "z dwoma argumentami: " << endl;
|
||||||
|
rysujLinie('+', 10);
|
||||||
|
}
|
||||||
8
uczelnia/2_semestr/programowanie/laby/lab2/zad7.cpp
Normal file
8
uczelnia/2_semestr/programowanie/laby/lab2/zad7.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// pole kwadratu
|
||||||
|
int pole(int a) { return a * a; }
|
||||||
|
|
||||||
|
// pole prostokąta
|
||||||
|
int pole(int a, int b = 1) { return a * b; }
|
||||||
|
|
||||||
|
// kod jest problematyczny, ponieważ nazwy funkcji są niejasne: użytkownik nie ma
|
||||||
|
// łatwego sposobu, by zrozumieć co, która funkcja robi.
|
||||||
14
uczelnia/2_semestr/programowanie/laby/lab2/zad8.cpp
Normal file
14
uczelnia/2_semestr/programowanie/laby/lab2/zad8.cpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
double srednia(int a, int b, int c) { return (double)(a + b + c) / 3; }
|
||||||
|
void wyzeruj(int &x) { x = 0; }
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cout << "Średnia 2,2,3 to: " << srednia(2,2 , 3) << endl;
|
||||||
|
int a = 6;
|
||||||
|
cout << "a = " << a << endl;
|
||||||
|
cout << "zerujemy" << endl;
|
||||||
|
wyzeruj(a);
|
||||||
|
cout << "a = " << a << endl;
|
||||||
|
}
|
||||||
30
uczelnia/2_semestr/programowanie/laby/lab2/zad9.cpp
Normal file
30
uczelnia/2_semestr/programowanie/laby/lab2/zad9.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
double srednia(int a, int b, int c) { return (double)(a + b + c) / 3; }
|
||||||
|
|
||||||
|
double srednia(int a, int b) { return (double)(a + b) / 2; }
|
||||||
|
|
||||||
|
double srednia(int a, int b, int c, int d) {
|
||||||
|
return (double)(a + b + c + d) / 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool czyZaliczyl(double wynik, double prog = 3.0) { return wynik >= prog; }
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a, b, c;
|
||||||
|
cout << "Podaj a: ";
|
||||||
|
cin >> a;
|
||||||
|
cout << "Podaj b: ";
|
||||||
|
cin >> b;
|
||||||
|
cout << "Podaj c: ";
|
||||||
|
cin >> c;
|
||||||
|
|
||||||
|
double avg = srednia(a, b, c);
|
||||||
|
cout << "Twoja średnia wynosi: " << avg << endl;
|
||||||
|
if (czyZaliczyl(avg)) {
|
||||||
|
cout << "Zaliczyłeś, brawo!" << endl;
|
||||||
|
} else {
|
||||||
|
cout << "Nie zaliczyłeś :(" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
Kod greja niezależnie od ilości argumentów można uszeregować (cokolwiek miałoby to znaczyć)
|
||||||
|
|
||||||
|
Dwumiarowa tablica prawdy — siatka Karnaugh (tabela/mapa)
|
||||||
|
*jak można zarabiać na mówieniu i mówić w tak nudny sposób????*
|
||||||
|
|
||||||
|
Numeracja w siatce Karanaugh jest istotna i zawsze stała!
|
||||||
|
|
||||||
|
| c\ba | 00 | 01 | 11 | 10 |
|
||||||
|
| ---- | ------ | ------ | ------ | ---------- |
|
||||||
|
| 0 | $_{0}$ | $_{1}$ | $_{2}$ | $_{3}$ |
|
||||||
|
| 1 | $_{4}$ | $_{5}$ | $_{6}$ | $_{7}$<br> |
|
||||||
|
Liczba kratek w grupie musi być równa potędze liczby 2.
|
||||||
|
|
||||||
|
o co tutaj chodzi
|
||||||
@@ -2,4 +2,7 @@
|
|||||||
|
|
||||||
Kanoniczna forma sumacyjna: oczekujemy postaci sumy mintermów.
|
Kanoniczna forma sumacyjna: oczekujemy postaci sumy mintermów.
|
||||||
|
|
||||||
Postać standardowa funkcji boolowskiej może być sumacyjna lub iloczynowa, mogą występować termy o różnej liczbie literałów (czyli niekoniecznie max/mintermy).
|
Postać standardowa funkcji boolowskiej może być sumacyjna lub iloczynowa, mogą występować termy o różnej liczbie literałów (czyli niekoniecznie max/mintermy).
|
||||||
|
|
||||||
|
[[Minimalizacja funkcji logicznych]]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user