Построить график функций - C#

Узнай цену своей работы

Формулировка задачи:

Необходимо составить код для консольного приложения С# по четырем задачам: 1) Компьютер строит график функции y=a*x^2+b*x+c. Переменные a, b, c задает пользователь. 4) Компьютер строит график функции y=a/x+b. Переменные a, b задает пользователь.

Решение задачи: «Построить график функций»

textual
Листинг программы
  1. using System;
  2.  
  3.  
  4.  
  5. namespace Program
  6. {
  7.     class program
  8.     {
  9.         static void Main()
  10.         {
  11.             int startposx = 200;//Начало координат
  12.             int startposy = 200;
  13.             Console.WriteLine("a=?");
  14.             int a = Int32.Parse(Console.ReadLine());
  15.             Console.WriteLine("b=?");
  16.             int b = Int32.Parse(Console.ReadLine());
  17.             Console.WriteLine("c=?");
  18.             int c = Int32.Parse(Console.ReadLine());
  19.             Console.Clear();
  20.             for (int i = 0; i < 200; i+=10)
  21.             {
  22.              
  23.                 Console.SetCursorPosition((startposx + i) / 10, (startposy ) / 10);
  24.                 Console.Write("*");
  25.                 Console.SetCursorPosition((startposx -i) / 10, (startposy) / 10);
  26.                 Console.Write("*");
  27.                 Console.SetCursorPosition((startposx ) / 10, (startposy+i) / 10);
  28.                 Console.Write("*");
  29.                 Console.SetCursorPosition((startposx ) / 10, (startposy-i) / 10);
  30.                 Console.Write("*");
  31.             }
  32.             Console.SetCursorPosition((startposx + 200) / 10, (startposy) / 10);
  33.             Console.Write("200");
  34.             Console.SetCursorPosition((startposx ) / 10, (startposy - 200) / 10);
  35.             Console.Write("200");
  36.             Console.SetCursorPosition((startposx - 200) / 10, (startposy) / 10);
  37.             Console.Write("-200");
  38.             Console.SetCursorPosition((startposx) / 10, (startposy -200) / 10);
  39.             Console.Write("-200");
  40.             Console.ForegroundColor = ConsoleColor.Red;
  41.             for (int x = 0; x < 10; x++)
  42.             {
  43.                 int y = a*x*x +b*x+c;//считаем уравнение
  44.                 Console.SetCursorPosition((startposx + x)/10, (startposy - y)/10);
  45.                 Console.Write("*");
  46.             }
  47.  
  48.  
  49.             Console.ReadLine();
  50.         }
  51.     }
  52.  
  53. }

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

14   голосов , оценка 3.857 из 5

Нужна аналогичная работа?

Оформи быстрый заказ и узнай стоимость

Бесплатно
Оформите заказ и авторы начнут откликаться уже через 10 минут
Похожие ответы