1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "stdafx.h"
#include "stdio.h"
#include <time.h>
#include <stdlib.h>
class vector
{
private:
int* m;
int size;
public :
vector(int n = 0);
vector(const vector &vector2);
~vector();
};
vector::vector( int n )
{
if (n < 0) n = 0;
size = n;
m = new int[n];
if(!m)
printf("Error");
else
m = NULL;
}
vector::vector(const vector &vector2)
{
size = vector2.size;
m = new int [size];
for(int i = 0; i<size;i++)
m[i] = vector2.m[i];
printf("kopia stvorena !");
}
vector::~vector()
{
delete[] m;
}
vector(int *m, int size)
{
srand(time(NULL))
if(!m)
printf("error")
else
for(int i = 0; i < size; i++)
m[i] = rand()% 99;
}
int main()
{
vector v1(45),
system("pause");
return 0;
}
Объяснение:
Program Math;
var
x1,x2,d,e,f, a, b, c: real;
begin
writeln('Решение квадратного уравнения(ax^2+bx+c=0).');
write('Введите a: ');
readln(a);
write('Введите b: ');
readln(b);
write('Введите c: ');
readln(c);
d:=sqr(b)-4*a*c;
writeln('вы ввели:');
writeln('a=',a:6:2);
writeln('b=' ,b:6:2);
writeln('c=',c:6:2);
writeln(' Дискриминант: D=b*b-4*a*c=',d:6:2);
if (d>0)
then begin
e:= (-b/(2*a));
f:= (sqrt(d)/(2*a));
writeln('D>= 0, значит корни действительные: ');
writeln('x1= ',(e-f):6:2);
writeln('x2= ',(e+f):6:2);
end;
if (d=0) then writeln('D=0, значит уравнение имеет 1 корень: x1= ',-b/2*a:6:2);
if (d<0) then writeln(' D<0, корней нет ');
end.