Нужно перевести с pascal abc net на с# - C#
Формулировка задачи:
Времени в обрез, а препод не принимает на паскале(( помогите пожалуйста
Листинг программы
- program pushka;
- uses
- graphABC;
- var
- x0, y0, x1, y1, x2, y2, t, r, f, k, b, u: real;
- const
- M = 1000;
- procedure qwe(x0, x1, f: real; var x2: real);
- begin
- x2 := f * x1 * t * t - x0 + 2 * x1;
- end;
- procedure asd(y0, y1, f: real; var y2: real);
- begin
- y2 := f * y1 * t * t - y0 + 2 * y1;
- end;
- procedure zxc(r: real; var f: real);
- begin
- f := -k * M / (abs(r * r) * abs(r))
- end;
- begin
- setwindowsize(1000,800);
- setbrushcolor(clyellow);
- circle(250, 250, 30);
- x0 := 150;
- y0 := -200;
- b := 6 ;
- u := 0;
- k := 10;
- t := 0.5;
- x1 := x0 + b * t;
- y1 := y0 + u * t;
- r := sqrt((x1 * x1) + (y1 * y1));
- repeat
- zxc(r, f);
- qwe(x0, x1, f, x2);
- asd(y0, y1, f, y2);
- r := sqrt((x2 * x2) + (y2 * y2));
- setbrushcolor(clblue);
- Circle(round(x2 + 250), round(250 - y2), 10);
- sleep(10);
- ClearWindow;
- setbrushcolor(clyellow);
- circle(250, 250, 30);
- x0 := x1; x1 := x2;
- y0 := y1; y1 := y2;
- until r<30
- end.
вот я попробовала, но движения не происходит
Листинг программы
- namespace lab9
- {
- public partial class Form1 : Form
- {
- double x0, y0, x1, y1, x2, y2, r, f, k, b, u;
- double t;
- const int M= 1000;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- void qwe(double x0, double x1, double f, double x2)
- {
- x2= f * x1 * t * t - x0 + 2 * x1;
- }
- void asd(double y0, double y1, double f, double y2)
- {
- y2= f* y1 * t* t - y0 + 2 * y1;
- }
- void zxc(double r, double f)
- {
- f = -k * M / (Math.Abs(r * r) * Math.Abs(r));
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = panel1.CreateGraphics();
- SolidBrush br1 = new SolidBrush(Color.Yellow);
- g.FillEllipse(br1, 250, 250, 50, 50);
- x0= 150;
- y0= -200;
- b= 6;
- u= 0;
- k= 10;
- t= 0.5;
- x1= x0 + b * t;
- y1= y0 + u * t;
- r= Math.Sqrt((x1 * x1) + (y1 * y1));
- while (r<50)
- {
- zxc(r, f);
- qwe(x0, x1, f, x2);
- asd(y0, y1, f, y2);
- r= Math.Sqrt((x2 * x2) + (y2 * y2));
- SolidBrush br2 = new SolidBrush(Color.Blue);
- g.FillEllipse(br2, (float)Math.Round(x2+250), (float)Math.Round(250-y2), 20, 20);
- System.Threading.Thread.Sleep(10);
- g.Clear(Color.White);
- g.FillEllipse(br1, 250, 250, 50, 50);
- x0= x1; x1= x2;
- y0= y1; y1= y2;
- }
- }
- }
- }
Решение задачи: «Нужно перевести с pascal abc net на с#»
textual
Листинг программы
- double x0, y0, x1, y1, x2, y2, r, f, k, b, u;
- double t;
- const int M = 1000;
- void qwe(double x0, double x1, double f)
- {
- x2 = f * x1 * t * t - x0 + 2 * x1;
- }
- void asd(double y0, double y1, double f)
- {
- y2 = f * y1 * t * t - y0 + 2 * y1;
- }
- void zxc(double r)
- {
- f = -k * M / (Math.Abs(r * r) * Math.Abs(r));
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- e.Graphics.FillEllipse(Brushes.Yellow, 250, 250, 50, 50);
- x0 = 150;
- y0 = -200;
- b = 6;
- u = 0;
- k = 10;
- t = 0.5;
- x1 = x0 + b * t;
- y1 = y0 + u * t;
- r = Math.Sqrt((x1 * x1) + (y1 * y1));
- while (r < 395)//Значение нужно уточнить
- {
- zxc(r);
- qwe(x0, x1, f);
- asd(y0, y1, f);
- r = Math.Sqrt((x2 * x2) + (y2 * y2));
- e.Graphics.FillEllipse(Brushes.Blue, (float)Math.Round(x2 + 250), (float)Math.Round(250 - y2), 20, 20);
- System.Threading.Thread.Sleep(10);
- e.Graphics.Clear(panel1.BackColor);
- e.Graphics.FillEllipse(Brushes.Yellow, 250, 250, 50, 50);
- x0 = x1; x1 = x2;
- y0 = y1; y1 = y2;
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д