kruttorg
?>

Решите задачу по информатике

Информатика

Ответы

zdl2008
Using System;
namespace Fractions{    public struct Fraction : IComparable<Fraction>    {        public Fraction(int numerator, int denominator)        {            Numerator = numerator;            Denominator = denominator;        }
        public int Numerator;        public int Denominator;
        public int CompareTo(Fraction other)        {            return (Numerator * other.Denominator).CompareTo(other.Numerator * Denominator);        }    }
    public class Program    {        static void Main(string[] args)        {            int numerator, denominator;
            Console.Write("Числитель первой дроби ");            numerator = int.Parse(Console.ReadLine());            Console.Write("Знаменатель первой дроби ");            denominator = int.Parse(Console.ReadLine());            var fraction1 = new Fraction(numerator, denominator);
            Console.Write("Числитель второй дроби ");            numerator = int.Parse(Console.ReadLine());            Console.Write("Знаменатель второй дроби ");            denominator = int.Parse(Console.ReadLine());            var fraction2 = new Fraction(numerator, denominator);
            var compareResult = fraction1.CompareTo(fraction2);            if (compareResult < 0)                Console.WriteLine("<");            else if (compareResult > 0)                Console.WriteLine(">");            else // = 0                Console.WriteLine("=");        }    }}
Panei
Const e=0.001;
var x,xn,h,an,s,f,y:real; n,k,i:integer;
begin
n:=10;
h:=(1-0.1)/(n-1);
x:=0.1-h;
for i:=1 to n do
 begin
 x:=x+h; an:=1;
 xn:=1; f:=1;
 k:=0;  s:=1;
 while an>e do
  begin
  xn:=xn*x*x;
  k:=k+1;
  f:=f*k;
  an:=(2*k+1)*xn/f;
  s:=s+an;
  end;
 y:=(1+2*x*x)*exp(x*x);
 writeln('x = ',x:4:1,'  s = ',s:6:4,'  y = ',y:6:4);
 end;
end.

Результат:
x = 0.1  s = 1.0303  y = 1.0303
x = 0.2  s = 1.1241  y = 1.1241
x = 0.3  s = 1.2911  y = 1.2911
x = 0.4  s = 1.5490  y = 1.5490
x = 0.5  s = 1.9260  y = 1.9260
x = 0.6  s = 2.4653  y = 2.4653
x = 0.7  s = 3.2320  y = 3.2320
x = 0.8  s = 4.3240  y = 4.3240
x = 0.9  s = 5.8894  y = 5.8895
x = 1.0  s = 8.1548  y = 8.1548

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

Решите задачу по информатике
Ваше имя (никнейм)*
Email*
Комментарий*

Популярные вопросы в разделе

atlantika7
mamanger
maisa1991
Novikova
Yumashev
olesyadeinega41
Takhmina-Komarova1415
krasnova1977
Stepanovich_Makarov
Kuznetsova702
Dushko
Николаев
guujuu
pavtrusov
MislitskiiSergei1403