const n=5;
var a: array [1..n] of real;
i: integer;
begin
for i:=1 to n do begin readln(a[i]);
if i mod 2=1 then a[i]:=sqr(i);
writeln(i,' элемент массива равен : ',a[i]);
end;
end.
Var
a: array [1..4] of char;
i: integer;
begin
a[1] := 'S';
a[2] := 'I';
a[3] := 'M';
a[4] := 'A';
for i := 1 to 4 do
write(ord(a[i]) - 64, ' ');
end.
а самостоятельно подобрать число никак?
#include <iostream>
#include <math.h>
using namespace std;
class Vertice {
public:
double x, y;
friend istream &operator>>(istream &is, Vertice &v) {
is >> v.x >> v.y ;
}
double distance(Vertice &w);
};
double Vertice::distance(Vertice &w) {
return sqrt( pow(this->x-w.x,2) + pow(this->y-w.y,2));
}
class Triangle {
public:
Vertice a, b, c;
Triangle(Vertice v, Vertice w, Vertice u);
double Square();
double Perimetr();
};
Triangle::Triangle(Vertice v, Vertice w, Vertice u) {
this->a = v, this->b = w, this->c = u;
}
double Triangle::Perimetr() {
return this->a.distance(this->b) + this->a.distance(this->c) + this->b.distance(this->c);
}
double Triangle::Square() {
double a = this->a.distance(this->b), b = this->b.distance(this->c), c = this->a.distance(this->c),
p = (a+b+c)/2;
return sqrt(p*(p-a)*(p-b)*(p-c));
}
int main() {
Vertice a, b , c;
cin >> a >> b >> c;
Triangle t(a,b,c);
cout << t.Perimetr() << endl << t.Square() << endl;
}
//язык c++, ООП
var a: array[1..10] of integer;
i,p: integer;
begin
randomize;
p:=1;
for i:=1 to 10 do begin
a[i]:=random(11)-5;
write(a[i],' ');
if a[i]<>0 then p:=p*a[i];
end;
writeln;
write('p=',p);
end.