Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Denkotleta221/5f880b8466d69da6f2469c42c7cbc533 to your computer and use it in GitHub Desktop.
Save Denkotleta221/5f880b8466d69da6f2469c42c7cbc533 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
setlocale(LC_ALL, "RU");
SetConsoleCP(CP_UTF8);
//1) Task
/*int answer = 0;
for (int i = 1; i <= 10; i++)
{
answer += i;
cout << answer << endl;
}*/
//2) Task
/*int celsium = 0;
int farengeit = 0 ;
for (int i = -10; i <= 100; i++)
{
celsium = i;
farengeit = (i * 9 / 5) + 32;
cout << celsium << "C = " << farengeit << "F \n";
}*/
//3) Task
//srand(time(0));
/*int negative_numbers = 0;
int positive_numbers = 0;
int zero = 0;
int even_numbers = 0;
int odd_numbers = 0;
for (int i = 0; i < 100; i++)
{
int rand_num = rand() % 201 - 100;
if (rand_num > 0) {
positive_numbers += 1;
}
else if (rand_num < 0) {
negative_numbers += 1;
}
else {
zero += 1;
}
if (rand_num % 2 == 0 and rand_num != 0) {
even_numbers += 1;
}
else if (rand_num % 1 == 0 and rand_num != 0) {
odd_numbers += 1;
}
}
cout << "Egative numbers: " << negative_numbers << endl;
cout << "Positive numbers: " << positive_numbers << endl;
cout << "Zero: " << zero << endl;
cout << "Even numbers: " << even_numbers << endl;
cout << "Odd numbers: " << odd_numbers;*/
//4) Task
/*int factorial = 0;
cout << "Enter your number for factorial: ";
cin >> factorial;
if (factorial == 0) {
cout << "0";
}
else {
int resalt = 1;
for (int i = 1; i <= factorial; i++)
{
resalt *= i;
}
cout << resalt;
}*/
//6) Task
/*int num;
cout << "Enter number: ";
cin >> num;
for (int i = 1; i < num; i++)
{
if (num % i == 0)
{
cout << i << endl;
}
}*/
//1. Написати програму, що показує таблицю множення(таблиця Піфагора).
/*for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
int sum = i * j;
cout << i << " * " << j << " = " << sum << endl;
}
cout << endl << endl << endl;
}*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment