-
Ввести масив із 5 чисел, а потім вивести його у зворотному порядку.
-
Створити масив із 20 випадкових чисел. Вивести всі елементи масиву з парними індексами.
-
Створити масив із 10 випадкових чисел у діапазоні від -20 до 20. Визначити кількість, суму та середнє арифметичне додатних елементів масиву.
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. Написати функцію Line, яку можна буде викликати так : Line(20, '@', 12, true); І при цьому горизонтально буде намальована лінія, що складається з 20 «собачок» червоного кольору.Якщо передати в останньому параметрі false, то лінія стане вертикальною. | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
void Line(int length, char symbol, int color, bool isHorizontal) { | |
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); | |
SetConsoleTextAttribute(h, color); | |
if (isHorizontal) { |
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 <string> | |
#include <windows.h> | |
using namespace std; | |
int main() { | |
SetConsoleOutputCP(1251); | |
string choice; | |
cout << "Вітаємо в текстовому квесті! Ти стоїш перед великими воротами замку.\n"; |
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
USE [master] | |
GO | |
/****** Object: Database [Store] Script Date: 13.01.2025 16:25:42 ******/ | |
CREATE DATABASE [Store] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'Store', FILENAME = N'C:\1\Store.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N'Store_log', FILENAME = N'C:\1\Store_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB ) | |
WITH CATALOG_COLLATION = DATABASE_DEFAULT, LEDGER = OFF |
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. Функції як об'єкти першого класу | |
# У Python функції можуть бути присвоєні змінним, передаватися як аргументи | |
# іншим функціям або навіть повертатися з функцій | |
def say_hello(): | |
print("Hello!") | |
greeting = say_hello # функція присвоєна змінній | |
greeting() # виклик функції через змінну |
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
# вбудовані функції: https://docs.python.org/uk/3.9/library/functions.html | |
text = "Hello" | |
print(len(text)) # 5 - повертає кількість елементів в об'єкті | |
print(type(text)) # <class 'str'> - повертає тип об'єкта | |
print(id(text)) # 2237317883936 - повертає унікальний ідентифікатор об'єкта | |
a = 5 | |
b = a | |
print(id(a)) # 140710135260200 |
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)] | |
# виведення списку |
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
#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
#include <iostream> | |
using namespace std; | |
void vegas(int& a, int& b) | |
{ | |
// обмін значеннями двох змінних | |
int temp = a; | |
a = b; | |
b = temp; | |
} |
NewerOlder