using System;
namespace Test
{
class Program
static void Main(string[] args)
double a, b, c;
a = Double.Parse(Console.ReadLine());
b = Double.Parse(Console.ReadLine());
c = Double.Parse(Console.ReadLine());
double D = b * b - 4.0 * a * c;
if (a == 0.0)
double x = -c / b;
Console.WriteLine("X = {0}", x);
}
else
if (b == 0.0 && -c / a > 0.0)
double x1 = Math.Sqrt(-c / a);
double x2 = -Math.Sqrt(-c / a);
Console.WriteLine("X1 = {0}, X2 = {1}", x1, x2);
if (D == 0.0)
double x = -b / (2.0 * a);
Console.WriteLine(x);
if (D > 0.0)
double x1 = (-b - Math.Sqrt(D)) / (2.0 * a);
double x2 = (-b + Math.Sqrt(D)) / (2.0 * a);
Console.WriteLine("D < 0, корней нет");
Console.ReadKey();
#include <iostream>
#include <vector>
#include <random>
int rand_num(int min, int max)
std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution<int> uni(min, max);
auto random_integer = uni(rng);
return random_integer;
int sum_vec(std::vector<int> v)
int sum = 0;
for (auto &num : v)
sum += num;
return sum;
void print_vec_2d(const std::vector<std::vector<int>>& v)
for (int i = 0; i < v.size(); ++i)
for (int j = 0; j < v[i].size(); ++j)
std::cout << v[i][j] << " ";
std::cout << std::endl;
void sort_vec_2d(std::vector<std::vector<int>>& v)
for (int j = i + 1; j < v.size(); ++j)
if (sum_vec(v[i]) > sum_vec(v[j]))
std::swap(v[i], v[j]);
void rand_vec_2d(std::vector<std::vector<int>>& v, int min, int max)
v.resize(rand_num(min, max));
for (int j = 0; j < rand_num(min, max); ++j)
v[i].push_back(rand_num(min, max));
int main()
setlocale(LC_ALL, "Russian");
std::vector<std::vector<int>> nums;
rand_vec_2d(nums, 1, 10);
std::cout << "Исходынй вектор: " << std::endl;
print_vec_2d(nums);
sort_vec_2d(nums);
std::cout << "Полученный вектор: " << std::endl;
//system("pause");
using System;
namespace Test
{
class Program
{
static void Main(string[] args)
{
double a, b, c;
a = Double.Parse(Console.ReadLine());
b = Double.Parse(Console.ReadLine());
c = Double.Parse(Console.ReadLine());
double D = b * b - 4.0 * a * c;
if (a == 0.0)
{
double x = -c / b;
Console.WriteLine("X = {0}", x);
}
else
if (b == 0.0 && -c / a > 0.0)
{
double x1 = Math.Sqrt(-c / a);
double x2 = -Math.Sqrt(-c / a);
Console.WriteLine("X1 = {0}, X2 = {1}", x1, x2);
}
else
if (D == 0.0)
{
double x = -b / (2.0 * a);
Console.WriteLine(x);
}
else
if (D > 0.0)
{
double x1 = (-b - Math.Sqrt(D)) / (2.0 * a);
double x2 = (-b + Math.Sqrt(D)) / (2.0 * a);
Console.WriteLine("X1 = {0}, X2 = {1}", x1, x2);
}
else
{
Console.WriteLine("D < 0, корней нет");
}
Console.ReadKey();
}
}
}
#include <iostream>
#include <vector>
#include <random>
int rand_num(int min, int max)
{
std::random_device rd;
std::mt19937 rng(rd());
std::uniform_int_distribution<int> uni(min, max);
auto random_integer = uni(rng);
return random_integer;
}
int sum_vec(std::vector<int> v)
{
int sum = 0;
for (auto &num : v)
{
sum += num;
}
return sum;
}
void print_vec_2d(const std::vector<std::vector<int>>& v)
{
for (int i = 0; i < v.size(); ++i)
{
for (int j = 0; j < v[i].size(); ++j)
{
std::cout << v[i][j] << " ";
}
std::cout << std::endl;
}
}
void sort_vec_2d(std::vector<std::vector<int>>& v)
{
for (int i = 0; i < v.size(); ++i)
{
for (int j = i + 1; j < v.size(); ++j)
{
if (sum_vec(v[i]) > sum_vec(v[j]))
{
std::swap(v[i], v[j]);
}
}
}
}
void rand_vec_2d(std::vector<std::vector<int>>& v, int min, int max)
{
v.resize(rand_num(min, max));
for (int i = 0; i < v.size(); ++i)
{
for (int j = 0; j < rand_num(min, max); ++j)
{
v[i].push_back(rand_num(min, max));
}
}
}
int main()
{
setlocale(LC_ALL, "Russian");
std::vector<std::vector<int>> nums;
rand_vec_2d(nums, 1, 10);
std::cout << "Исходынй вектор: " << std::endl;
print_vec_2d(nums);
sort_vec_2d(nums);
std::cout << "Полученный вектор: " << std::endl;
print_vec_2d(nums);
//system("pause");
}