Készíts egy grafikus programot Pascalban, amelyik megmutatja hogy egy kör köré hány kör írható? Ennyit mondott a tanárom.





Ez is egy módja annak, hogy lehet a rezet eladni,
aranynak.










program Circles;
uses
Graph;
var
Gd, Gm: Integer;
Width, Height: Integer;
{RadiusRate - The rate between the size of the central
circle and the circles around it.}
procedure DrawCircles(SizeRate: Double);
var
Radius, R: Integer;
Center, C: PointType;
I, N : Integer;
Degree : Double;
begin
Radius := Height div 8;
Center.X := Width div 2;
Center.Y := Height div 2;
SetColor(Black);
Circle(Center.X, Center.Y, Radius);
R := Round(Radius*SizeRate);
N := Round(2*(Radius+R)*Pi/(2*R));
Write('We can draw ',N,' circles with radius ',R);
Writeln(' around a circle with radius ',Radius,'.');
for I := 0 to N - 1 do
begin
if (N <> 0) then
Degree := I*2*Pi/N
else
Degree := 0;
C.X := Center.X + Round((Radius+R)*cos(Degree));
C.Y := Center.Y + Round((Radius+R)*sin(Degree));
Circle(C.X, C.Y, R);
end;
end;
begin
Gd := Detect;
Gm := 0;
InitGraph(Gd, Gm, '');
if GraphResult <> grOk then
Halt(1);
SetFillStyle(SolidFill, LightGray);
Width := GetMaxX;
Height := GetMaxY;
Bar(0, 0, Width, Height);
DrawCircles(1/1);
DrawCircles(1/8);
Readln;
CloseGraph;
end.





@#13:
Kafa lett.
Nálam reklamált a fordító a Gd, Gm: Integer; sornál, az integer helyett smallint kellett neki (csak megemlítem, hátha Kérdező is beleakad).





Fú, akkor nagyon kell igyekezned, hogy alaposan kiélvezhesd! Itt egy másik megközelítés, #13 programjának átbarkácsolásával (én már teljesen elfelejtettem a Graph unitot):
Elnézést, ha a megfogalmazásaim nem egészen korrektek, majd te átírod.
P.S.: Ez a Hastebin meg elmehet a sunyiba. Rihehuleye.pas! Ilyen hülye nevet adni az áldozatos munkám gyümölcsének, lám, ezt kellett hajlott koromra megérnem...















'Vajon mikor kopik már ki az országból ez a szerencsétlen, semmire nem jó Pascal? Tényleg nem értem, minek erőltetni - senki, sehol nem használja, mert nem alkalmas semmi értelmes dologra. '
Tudod kiscsillag majd ha megismerted akkor mondj véleményt. Egy legfrissebb Delphi alsó hangon másfél misi körül van és megveszik.
Kapcsolódó kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!