Advertisement
Guest User

pr7

a guest
Oct 10th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2.  
  3. class MainClass
  4. {
  5. static double f(double x)
  6. {
  7. try
  8. {
  9. if (4-x*x <1) throw new Exception();
  10. else return Math.Log(4-x*x);
  11. }
  12. catch
  13. {
  14. throw;
  15. }
  16. }
  17.  
  18. public static void Main ()
  19. {
  20. try
  21. {
  22. Console.Write("a=");
  23. double a = double.Parse(Console.ReadLine());
  24. Console.Write("b=");
  25. double b = double.Parse(Console.ReadLine());
  26. Console.Write("h=");
  27. double h = double.Parse(Console.ReadLine());
  28. for (double i = a; i <= b; i += h)
  29. try
  30. {
  31. Console.WriteLine("y({0})={1:f4}", i, f(i));
  32. }
  33. catch
  34. {
  35. Console.WriteLine("y({0})=error", i);
  36. }
  37. }
  38. catch (FormatException)
  39. {
  40. Console.WriteLine("Неверный формат ввода данных");
  41. }
  42. catch
  43. {
  44. Console.WriteLine("Неизвестная ошибка");
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement