Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace razrabotka
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] buf = new string[256];
- var x = new List<float>();
- var f = new List<float>();
- System.IO.StreamReader file =
- new System.IO.StreamReader(args[0]);
- while (( buf[0] = file.ReadLine()) != null)
- {
- buf = buf[0].Split(' ');
- foreach (var s in buf)
- {
- string temp = s;
- if(temp.Contains('f'))
- {
- temp = temp.Remove(temp.IndexOf('f'), 6);
- temp = temp.Remove(temp.IndexOf(';'), 1);
- float tmpf = 0;
- float.TryParse(temp, out tmpf);
- f.Add(tmpf);
- }
- else if (temp.Contains('x'))
- {
- temp = temp.Remove(temp.IndexOf('x'), 3);
- temp = temp.Remove(temp.IndexOf(';'), 1);
- float tmpx = 0;
- float.TryParse(temp, out tmpx );
- x.Add(tmpx);
- }
- }
- }
- file.Close();
- float f2 = f[0] + ((f[1] - f[0]) * (x[1] - x[0])) / (x[2] - x[0]);
- double k = (f[1] - f[0]) / (x[2] - x[0]);
- double b = (x[2] * f[0] - f[1] * x[0]) / (x[2] - x[0]);
- Console.WriteLine("функия : f(x) = ({0})*x+({1});",k,b);
- Console.WriteLine("f({0})= {1}", x[1], f2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement