<em>// PascalABC.NET 3.2</em>
begin
var a:array[1..9] of integer;
var i:=1;
while i<=7 do begin
a[i]:=i*i+5;
a[i+1]:=Trunc(sqrt(a[i]));
a[i+2]:=a[i] div a[i+1];
i:=i+3
end;
for var j:=1 to 9 do Write(a[j],' ');
Writeln
end.
<u>Результат</u>
6 2 3 21 4 5 54 7 7
===== PascalABC.NET
begin
var s := 0.0;
for var i := 1 to ReadInteger('n =') do
s += 1 / Sqrt(i);
Println(s)
end.
Решение в прикрепленном файле в 3-х циклах, но работать эта программа будет медленнее,
если число N - простое.
Unit proect;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, TAGraph, TASeries,Forms,
Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Chart1: TChart;
Image5: TImage;
Image6: TImage;
Label14: TLabel;
Label15: TLabel;
SinSeries2: TLineSeries;
CosSeries2: TLineSeries;
Edit3: TEdit;
Edit4: TEdit;
Edit1: TEdit;
Edit2: TEdit;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Label1: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Shape1: TShape;
SinSeries: TLineSeries;
CosSeries: TLineSeries;
SinCosSeries: TLineSeries;
procedure Button1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
const
N = 100;
MIN = -5;
MAX = 5;
var
x, step: Double;
a, b, c, d, i: Integer;
begin
//чистка предыдущих графиков
//считываем переменные
a := StrToInt(Edit1.Text);
b := StrToInt(Edit2.Text);
c := StrToInt(Edit3.Text);
d := StrToInt(Edit4.Text);
step := (MAX - MIN) / N;
x := MIN;
repeat
//Рисуем графики
SinSeries.AddXY(x, a * x + b);
CosSeries.AddXY(x, d * x * x);
SinCosSeries.AddXY(x, c / x);
SinSeries2.AddXY(x, sin(x));
CosSeries2.AddXY(x, cos(x));
//следующий
x := x + step;
until x > MAX;
end;
end.
Ответ:Как то так
Объяснение:
m = int(input("Введите месяц: "))
d = int(input("Введите день: "))
while d <= 31:
print("Месяц: " + str(m),"День: " + str(d))
d += 7
if m == 9 and d > 30:
m = 10
d -= 30
if m == 10 and d > 31:
m = 11
d -= 31
if m == 11 and d > 30:
m = 12
d -= 30
if m == 10 and d > 31:
m = 11
d -= 31
if m == 11 and d > 30:
m = 12
d -= 30
if m == 11 and d > 30:
m = 12
d -= 30