Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Denkotleta221/7947bb8712ddad074a0bb4dfd7e2e62c to your computer and use it in GitHub Desktop.
Save Denkotleta221/7947bb8712ddad074a0bb4dfd7e2e62c to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <algorithm>
#include <iomanip>
#include <conio.h>
#include <ctime>
using namespace std;
//1) Task
void Line(int kol, char sumbol, int num, bool is_bool) {
if (is_bool) {
for (int i = 0; i < kol; i++)
{
cout << sumbol << endl;
}
}
else {
for (int i = 0; i < kol; i++)
{
cout << sumbol;
}
}
}
//2) Task
void Rectangle(int width, int height, char border = '#', char fill = ' ',int x = 0, int y = 0) {
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if (i == 0 || i == height - 1 || j == 0 || j == width - 1)
cout << border;
else
cout << fill;
}
cout << endl;
}
}
//3) Task
void Cube(int num) {
int sum = num * num * num;
cout << sum;
}
//4) Task
void SimpleNumber(int num) {
bool is_true = true;
if (num < 2) {
is_true = false;
};
for (int i = 2; i * i <= num; i++) {
if (num % i == 0) {
is_true = false;
};
}
if (is_true) {
cout << "Yes";
}
else {
cout << "No";
}
}
int main()
{
srand(time(0));
setlocale(LC_ALL, "RU");
SetConsoleCP(CP_UTF8);
//1) Task
/*Line(10, '!', 12, false);
Line(10, '!', 12, true);*/
//2) Task
//Rectangle(10, 5, '*', '-', 2, 3);
//3) Task
//Cube(10);
//4) Task
//SimpleNumber(307);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment