CS
cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("f(n) = ax^2 + bx + c");
string txt = Console.ReadLine();
string[] stringSeparators = new string[] {"f(",")"," ", "=","x","^2"};
string[] result = txt.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
int x = int.Parse(result[0]);
int a = int.Parse(result[1]);
string op1 = result[2];
int b = int.Parse(result[3]);
string op2 = result[4];
int c = int.Parse(result[5]);
double f = a * Math.Pow(x,2);
if(op1 == "+") f += b * x;
else f -= b * x;
if(op2 == "+") f += c;
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run