求助将一段C#语言转成c++语言
  • 浏览:748 评论:1 人

  • 具体是一个函数的C#我想要c++语言
    语言是画一个函数图像,如下网址
    https://www.tuicool.com/articles/QrA3umV


    c#语言 如下 建议还是打开网页看吧 有不辞辛苦的童鞋吗?特别感谢。
    // Draw the graph.private void DrawGraph(){ const float wxmin = -2; const float wxmax = 2; const float wymin = -2; const float wymax = 2; int wid = picGraph.ClientSize.Width; int hgt = picGraph.ClientSize.Height; Bitmap bm = new Bitmap(wid, hgt); using (Graphics gr = Graphics.FromImage(bm)) { gr.SmoothingMode = SmoothingMode.AntiAlias; RectangleF rect = new RectangleF( wxmin, wymin, (wxmax - wxmin), (wymax - wymin)); PointF[] points = { new PointF(0, hgt), new PointF(wid, hgt), new PointF(0, 0), }; gr.Transform = new Matrix(rect, points); Matrix inverse = gr.Transform; inverse.Invert(); // Draw the axes. using (Pen pen = new Pen(Color.Red, 0)) { gr.DrawLine(pen, wxmin, 0, wxmax, 0); gr.DrawLine(pen, 0, wymin, 0, wymax); } // Plot the function. // Convert X coordinates for each pixel into world coordinates. PointF[] values = new PointF[wid]; for (int i = 0; i < wid; i++) values.X = i; inverse.TransformPoints(values); // Generate Y values. for (int i = 0; i < wid; i++) values.Y = F(values.X, A, B); // Plot. using (Pen pen = new Pen(Color.Black, 0)) { gr.DrawLines(pen, values); } } picGraph.Image = bm;}