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 <fstream> | |
#include <string> | |
#include <windows.h> | |
using namespace std; | |
// Структура для зберігання даних про продукт | |
struct Product { | |
string name; |
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. Вивести кількість товарів кожної категорії, середня ціна поставки яких більше 100 гривень. | |
SELECT c.name AS [Категорія], COUNT(DISTINCT p.id) AS [Кількість товарів] | |
FROM Product p | |
JOIN Category c ON p.id_category = c.id | |
JOIN Delivery d ON p.id = d.id_product | |
GROUP BY c.name | |
HAVING AVG(d.price) > 100; | |
-- 2. Показати категорії "Фрукти" та "Цукерки", їхні товари та загальну суму їх продажу. | |
SELECT c.name AS [Категорія], p.name AS [Товар], SUM(s.price) AS [Загальна сума продажу] |
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) Від 1 до n. | |
// Дано натуральне число n.Виведіть усі числа від 1 до n. | |
// Вхід: 5 | |
// Вихід : 1 2 3 4 5 | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
void show(int from, int to) { | |
cout << from << " "; |
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. Показати назви товарів та їх виробників, а також тих виробників, у яких немає товарів. | |
SELECT p.name AS [назва товару], pr.name AS [назва виробника] | |
FROM Product p | |
RIGHT OUTER JOIN Producer pr ON p.id_producer = pr.id; | |
-- 2. Показати лише ті категорії, до яких не належить жоден товар. | |
SELECT c.name AS [назва категорії] | |
FROM Category c | |
LEFT OUTER JOIN Product p ON c.id = p.id_category | |
WHERE p.id IS NULL; |
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> // COORD, HANDLE, SetConsoleTextAttribute, SetConsoleCursorPosition | |
#include <conio.h> // _getch, _kbhit | |
#include <string> | |
using namespace std; | |
// ENUMS | |
enum GameObject : short { HALL, WALL, COIN, ENEMY, MEDKIT }; | |
enum Color : short { | |
BLACK, DARKBLUE, DARKGREEN, TURQUOISE, DARKRED, |
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. Показати назви та категорії товарів, постачальниками яких є ООО "Паньки" або ООО "Які люди". | |
SELECT p.name [назва товару], | |
c.name [категорія] | |
FROM Product p | |
JOIN Category c ON p.id_category = c.id | |
JOIN Supplier s ON p.id_supplier = s.id | |
WHERE s.name IN ('ООО "Паньки"', 'ООО "Які люди"'); | |
-- 2. Вибрати всі товари з вказівкою їх постачальника, ім'я виробника яких не містить літер [АКМ], і категорія яких не "Крупи" | |
SELECT p.name AS [назва товару], |
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
// Одновимірні масиви: | |
// 1. Ввести масив із 5 чисел, а потім вивести його у зворотному порядку. | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
const int size = 5; | |
int ar[size]; | |
for (int i = 0; i < size; 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
// Завдання на один простий цикл while / do while / for | |
// 1. Обчислити суму чисел в діапазоні від 1 до 10 циклом. | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
int main() { | |
SetConsoleOutputCP(1251); | |
int sum = 0; | |
for (int i = 1; i <= 10; 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
--1. Порахувати можливий дохід за хліб та молоко (з урахуванням знижок на ці товари) | |
SELECT name, price, discount, quantity, ROUND(price * (1 - discount / 100) * quantity, 2) AS [income] | |
FROM Products | |
WHERE name IN ('bread', 'milk') | |
--2. Отримати інформацію про товари, які були доставлені вчора і сьогодні більше 10 одиниць (getdate, dateadd) | |
SELECT name, price, quantity, date_of_delivery | |
FROM Products | |
WHERE (date_of_delivery = CAST(GETDATE() AS DATE) OR date_of_delivery = CAST(DATEADD(DAY, -1, GETDATE()) AS DATE)) AND quantity > 10 |
NewerOlder