This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <windows.h> | |
| using namespace std; | |
| const int k = 5; // chess board size | |
| int ar[k][k]; | |
| const int shift_count = 8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <windows.h> | |
| using namespace std; | |
| const int quantity = 5; | |
| int sterjen1[quantity]{}, sterjen2[quantity]{}, sterjen3[quantity]{}; | |
| void moveDisc(int from[], int to[]) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <conio.h> | |
| #include <iostream> | |
| using namespace std; | |
| int z = 0; // кількість варіантів розміщення | |
| char check(int A[], int n) | |
| { | |
| int i, j; | |
| for (i = 0; i < n; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| void swap(void *a, void *b, size_t size) | |
| { | |
| char *tmp = (char*) malloc(size); | |
| memcpy(tmp, a, size); | |
| memcpy(a, b, size); | |
| memcpy(b, tmp, size); | |
| free(tmp); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| // функція для демонстрації malloc | |
| void malloc_example() { | |
| system("title malloc example"); | |
| int k = 5; | |
| // malloc повертає вказівник на виділену пам'ять, сама пам'ять не ініціалізується | |
| int* ptr = (int*)malloc(k * sizeof(int)); // виділення пам'яті за допомогою malloc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| void vegas(int& a, int& b) | |
| { | |
| // обмін значеннями двох змінних | |
| int temp = a; | |
| a = b; | |
| b = temp; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| int main() { | |
| setlocale(LC_ALL, "Ukrainian"); | |
| int staticArr[10]; // статичний масив | |
| int* dynamicArr = new int[10]; // динамічний масив |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace AssociationExample | |
| { | |
| public class Person | |
| { | |
| public string? Name { get; set; } // асоціація (поле з типом іншого класу) | |
| public string? Surname { get; set; } | |
| public string SaySomething() // асоціація (повернення значення з типом іншого класу, string) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace AggregationExample | |
| { | |
| public class Hat | |
| { | |
| public string Color { get; set; } | |
| public string Model { get; set; } | |
| public double Price { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| namespace CompositionExample | |
| { | |
| public class PegLeg // дерев'яна нога | |
| { | |
| public string Color { get; set; } | |
| public bool Dirty { get; set; } | |
| public double Length { get; set; } | |
| public int Usability { get; set; } |