На языке C++ будет так:
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a,b,c;
double D, x1, x2;
cout<<"Введите a"<<endl;
cin >>a;
cout<<"Введите b"<<endl;
cin >>b;
cout<<"Введите c"<<endl;
cin >>c;
if (a == 0){
cout<<"Коэффициент a не может быть равен 0"<<endl;
return 0;
}
D = b*b - 4 * a * c;
if (D >= 0){
if (D == 0){
x1 = -(double)b /(2*a);
cout<<"x = "<<x1<<endl;
}
else{
x1 = (-b + sqrt(D)) / (2*a);
x2 = (-b - sqrt(D)) / (2*a);
cout<<"x1 = "<<x1<<endl;
cout<<"x2 = "<<x2<<endl;
}
}
else{
cout<<"Корней нет. D = "<<D<<endl;
}
return 0;
}
begin
var a:=ArrRandom(100,-20,20); a.Println;
WritelnFormat('Положительных {0}, отрицательных {1}',
a.Where(x->x>0).Count,a.Where(x->x<0).Count)
end.
Тестовое решение:
-19 12 19 -17 -5 10 -13 -2 -4 16 -6 -12 -3 5 -3 -6 -1 8 -19 -14 -1 9 -10 20 -7 20 5 17 -7 11 -5 -14 -19 -18 16 13 11 -2 -3 9 1 11 10 -13 8 -14 -15 -13 8 5 -7 20 -20 18 2 -8 2 19 10 -5 -15 -10 -16 5 1 -12 -14 -6 9 5 3 -20 -9 -7 6 9 20 -18 -8 -13 14 -3 -11 9 -3 -5 -15 -16 0 4 -10 12 8 -19 4 -10 6 -15 7 0
Положительных 44, отрицательных 54