Построить график функций - C#
Формулировка задачи:
Необходимо составить код для консольного приложения С# по четырем задачам:
1) Компьютер строит график функции y=a*x^2+b*x+c. Переменные a, b, c задает пользователь.
4) Компьютер строит график функции y=a/x+b. Переменные a, b задает пользователь.
Решение задачи: «Построить график функций»
textual
Листинг программы
- using System;
- namespace Program
- {
- class program
- {
- static void Main()
- {
- int startposx = 200;//Начало координат
- int startposy = 200;
- Console.WriteLine("a=?");
- int a = Int32.Parse(Console.ReadLine());
- Console.WriteLine("b=?");
- int b = Int32.Parse(Console.ReadLine());
- Console.WriteLine("c=?");
- int c = Int32.Parse(Console.ReadLine());
- Console.Clear();
- for (int i = 0; i < 200; i+=10)
- {
- Console.SetCursorPosition((startposx + i) / 10, (startposy ) / 10);
- Console.Write("*");
- Console.SetCursorPosition((startposx -i) / 10, (startposy) / 10);
- Console.Write("*");
- Console.SetCursorPosition((startposx ) / 10, (startposy+i) / 10);
- Console.Write("*");
- Console.SetCursorPosition((startposx ) / 10, (startposy-i) / 10);
- Console.Write("*");
- }
- Console.SetCursorPosition((startposx + 200) / 10, (startposy) / 10);
- Console.Write("200");
- Console.SetCursorPosition((startposx ) / 10, (startposy - 200) / 10);
- Console.Write("200");
- Console.SetCursorPosition((startposx - 200) / 10, (startposy) / 10);
- Console.Write("-200");
- Console.SetCursorPosition((startposx) / 10, (startposy -200) / 10);
- Console.Write("-200");
- Console.ForegroundColor = ConsoleColor.Red;
- for (int x = 0; x < 10; x++)
- {
- int y = a*x*x +b*x+c;//считаем уравнение
- Console.SetCursorPosition((startposx + x)/10, (startposy - y)/10);
- Console.Write("*");
- }
- Console.ReadLine();
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д