Разработать программу для вычисление следующей сумы степного ряду ∑_(n=1) k-верхняя граница x^n/n с заданной точностью ε используя следующую рекурентную формулу U_m=U_n*x*n/(n-1), |x|<1 , m= n+1. Контрольный пример
1)var a:array [0..5] of Integer; i,j:Integer; begin Randomize; j:=0; for i:=0 to 5 do a[i]:=Random(100); for i:=0 to 5 do if a[i] mod 3 =0 then Inc(j); Writeln(j); readln; 2)var a:array [0..5] of Integer; i,j:Integer; begin Randomize; j:=0; for i:=0 to 5 do a[i]:=Random(100); for i:=0 to 5 do if a[i] mod 2 =0 then j:=j+a[i]; Writeln(j); readln; 3)a:array [0..5] of Integer; i,s:Integer; begin Randomize; s:=1; for i:=0 to 5 do a[i]:=Random(9)+1; for i:=0 to 5 do if i mod 2 <>0 then s:=s*a[i]; Writeln(s); readln; end. 4)const n=5;m=5; var a:array [0..n,0..m] of Integer; i,j:Integer; begin Randomize; for i:=0 to n do for j:=0 to m do a[i,j]:=Random(100); for i:=0 to n do begin Writeln; for j:=0 to m do write(a[i,j]:3); end; for i:=0 to n do for j:=0 to m do begin if a[i,j] mod 2 =0 then a[i,j]:=2 else if a[i,j] mod 2 <>0 then a[i,j]:=1; end; Writeln; for i:=0 to n do begin Writeln; for j:=0 to m do write(a[i,j]:3); end; Readln; end. 5)const n=5;m=5; var a:array [0..n,0..m] of Integer; i,j:Integer; begin Randomize; for i:=0 to n do for j:=0 to m do a[i,j]:=Random(10); for i:=0 to n do begin Writeln; for j:=0 to m do write(a[i,j]:3); end; for i:=0 to n do for j:=0 to m do a[i,j]:=a[i,j]*2; Writeln; for i:=0 to n do begin Writeln; for j:=0 to m do write(a[i,j]:3); end; Readln; end.
using System;
class Program
{
static void Main()
{
int x1 = 2, y1 = 1;
int x2 = 6, y2 = 5;
int x3 = 10, y3 = 1;
var a = Distance(x2, y2, x3, y3);
var b = Distance(x1, y1, x3, y3);
var c = Distance(x2, y2, x1, y1);
Console.WriteLine("S = {0}", Square(a, b, c));
Console.ReadKey();
}
//растояние между точками
static double Distance(int x1, int y1, int x2, int y2)
{
return Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}
//формула герона
static double Square(double a, double b, double c)
{
var p = (a + b + c) / 2;
return Math.Sqrt(p * (p - a) * (p - b) * (p - c));
}
// теорема косинусов
static double Angle(double a, double b, double c)
{
return Math.Acos((b * b + c * c - a * a) / (2 * b * c));
}
static bool IsAcuteAngel(double alpha)
{
return alpha < Math.PI / 2;
}
}
1)var a:array [0..5] of Integer; i,j:Integer;
begin
Randomize;
j:=0;
for i:=0 to 5 do
a[i]:=Random(100);
for i:=0 to 5 do
if a[i] mod 3 =0 then
Inc(j);
Writeln(j);
readln;
2)var a:array [0..5] of Integer; i,j:Integer;
begin
Randomize;
j:=0;
for i:=0 to 5 do
a[i]:=Random(100);
for i:=0 to 5 do
if a[i] mod 2 =0 then
j:=j+a[i];
Writeln(j);
readln;
3)a:array [0..5] of Integer; i,s:Integer;
begin
Randomize;
s:=1;
for i:=0 to 5 do
a[i]:=Random(9)+1;
for i:=0 to 5 do
if i mod 2 <>0 then
s:=s*a[i];
Writeln(s);
readln;
end.
4)const n=5;m=5;
var a:array [0..n,0..m] of Integer; i,j:Integer;
begin
Randomize;
for i:=0 to n do
for j:=0 to m do
a[i,j]:=Random(100);
for i:=0 to n do
begin
Writeln;
for j:=0 to m do
write(a[i,j]:3);
end;
for i:=0 to n do
for j:=0 to m do
begin
if a[i,j] mod 2 =0 then
a[i,j]:=2
else if a[i,j] mod 2 <>0 then
a[i,j]:=1;
end;
Writeln;
for i:=0 to n do
begin
Writeln;
for j:=0 to m do
write(a[i,j]:3);
end;
Readln;
end.
5)const n=5;m=5;
var a:array [0..n,0..m] of Integer; i,j:Integer;
begin
Randomize;
for i:=0 to n do
for j:=0 to m do
a[i,j]:=Random(10);
for i:=0 to n do
begin
Writeln;
for j:=0 to m do
write(a[i,j]:3);
end;
for i:=0 to n do
for j:=0 to m do
a[i,j]:=a[i,j]*2;
Writeln;
for i:=0 to n do
begin
Writeln;
for j:=0 to m do
write(a[i,j]:3);
end;
Readln;
end.