Poprawki AiSD

This commit is contained in:
2025-05-15 15:25:50 +02:00
parent 9fb3babfa0
commit 72826f26b6
8 changed files with 40 additions and 51 deletions
@@ -0,0 +1,44 @@
program rownanie_kwadratowe;
var
a,b,c : Double;
x,x1,x2 : Double;
Delta : Double;
begin
write('Podaj a: ');
ReadLn(a);
write('Podaj b: ');
ReadLn(b);
write('Podaj c: ');
ReadLn(c);
if a=0 then
begin
x:=c/b;
writeln('To jest rownanie liniowe');
writeln(x:0:5); // Wypisze pięć miejsc po przecinku zamiast naukowej notacji
end else
begin
Delta:=b*b-4*a*c;
if Delta < 0 then
writeln('Brak rozwiazan')
else
begin
if Delta > 0 then
begin
x1:=(-b - Sqrt(Delta))/(2*a);
x2:=(-b + Sqrt(Delta))/(2*a);
writeln('Dwa pierwiastki');
writeln(x1:0:5);
writeln(x2:0:5);
end else
begin
x:=b/(2*a);
writeln('Jeden pierwiastek');
writeln(x:0:5);
end;
end;
end;
end.
@@ -0,0 +1,37 @@
program rok_przestepny;
function Czytaj_rok: Integer;
var
rok: Integer;
begin
write('Podaj rok: ');
readln(rok);
Czytaj_rok:=rok;
end;
function Czy_przestepny(rok :Integer ): Boolean;
begin
Czy_przestepny:= ((rok mod 4 = 0) AND (NOT (rok mod 100 = 0)) ) OR (rok mod 400 = 0);
end;
procedure Wypisz_czy_przestepny(rok : Integer; przestepny: Boolean );
begin
if przestepny then
writeln('Rok ', rok, ' jest przestepny')
else
writeln('Rok ', rok, ' nie jest przestepny');
end;
procedure Glowna_procedura;
var
rok : Integer;
przestepny : Boolean;
begin
rok:= Czytaj_rok();
przestepny:= Czy_przestepny(rok);
Wypisz_czy_przestepny(rok,przestepny);
end;
begin
Glowna_procedura()
end.
@@ -0,0 +1,38 @@
program suma_cyfr;
function Czytaj_liczbe : Integer;
var
liczba : Integer;
begin
write('Podaj liczbe: ');
readln(liczba);
Czytaj_liczbe:=liczba;
end;
function Suma_cyfr(liczba : Integer) : Integer;
var suma : Integer;
begin
suma:=0;
liczba:=abs(liczba);
while liczba>0 do
begin
suma:=suma+(liczba mod 10);
liczba:=trunc(liczba/10);
end;
Suma_cyfr:=suma;
end;
procedure Wypisz_wynik(liczba : Integer; suma : Integer );
begin
writeln('Suma cyfr liczby ', liczba, ' to ', suma);
end;
procedure Glowna_procedura;
var liczba : Integer;
begin
liczba:=Czytaj_liczbe();
Wypisz_wynik(liczba,Suma_cyfr(liczba));
end;
begin
Glowna_procedura();
end.