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 - это пиксели |
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
# 1. створення списку | |
numbers = [10, 20, 30, 40, 50] | |
print("Початковий список:", numbers) | |
# 2. додавання елементів | |
# append() — додає один елемент в кінець списку | |
numbers.append(60) | |
print("Після append(60):", numbers) | |
# extend() — додає елементи з іншого списку в кінець поточного списку |
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
import random | |
import time | |
# розмір списку | |
size = 50000 | |
# список цілих чисел | |
ar = [random.randint(0, 9999) for _ in range(size)] | |
# виведення списку |
OlderNewer