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 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 <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> | |
#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 <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> | |
#include <conio.h> | |
using namespace std; | |
int main() { | |
srand(time(0)); // запуск генератора случайных чисел | |
system("title Snake Game"); | |
system("mode con cols=70 lines=31"); // установка размеров окна консоли | |
MoveWindow(GetConsoleWindow(), 50, 50, 2000, 2000, true); // установка стартовой позиции окна консоли (50 и 50 - это пиксели |
NewerOlder