fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace tmp_doprojektu_3
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. double Xd = -0.33;
  15. double Xg = 0.77;
  16. double X = 0.11;
  17. double h = 0.07;
  18.  
  19. Console.WriteLine ("wartość sumy dla X = {0}", X);
  20.  
  21. obliczSume(X);
  22.  
  23. Console.WriteLine("Wartosc sumy w otoczeniu X = {0}", X);
  24.  
  25. for (double i = Xd; i < Xg; i += h)
  26. obliczSume(i);
  27. obliczSume(Xg);
  28.  
  29. Console.ReadKey();
  30.  
  31. return;
  32.  
  33. }
  34.  
  35. static void obliczSume(double x)
  36. {
  37. double eps = 0.000001;
  38. double skladnik = 0;
  39. double suma = 0;
  40. int k = 1;
  41. if (Math.Abs(x) < eps)
  42.  
  43. {
  44. Console.WriteLine("Suma dla x = 0 jest rowna: 0");
  45. return;
  46. }
  47.  
  48. do
  49. {
  50. skladnik = Math.Pow(x, k) / k;
  51. suma += skladnik;
  52. ++k;
  53. }
  54. while (Math.Abs(skladnik) > eps);
  55. Console.WriteLine("Suma dla x = {0:F2} jest rowna {1:F3}", x, suma);
  56. }
  57. }
  58. }
  59.  
Success #stdin #stdout 0.01s 29664KB
stdin
Standard input is empty
stdout
wartość sumy dla X = 0.11
Suma dla x = 0.11 jest rowna 0.117
Wartosc sumy w otoczeniu X = 0.11
Suma dla x = -0.33 jest rowna -0.285
Suma dla x = -0.26 jest rowna -0.231
Suma dla x = -0.19 jest rowna -0.174
Suma dla x = -0.12 jest rowna -0.113
Suma dla x = -0.05 jest rowna -0.049
Suma dla x = 0.02 jest rowna 0.020
Suma dla x = 0.09 jest rowna 0.094
Suma dla x = 0.16 jest rowna 0.174
Suma dla x = 0.23 jest rowna 0.261
Suma dla x = 0.30 jest rowna 0.357
Suma dla x = 0.37 jest rowna 0.462
Suma dla x = 0.44 jest rowna 0.580
Suma dla x = 0.51 jest rowna 0.713
Suma dla x = 0.58 jest rowna 0.867
Suma dla x = 0.65 jest rowna 1.050
Suma dla x = 0.72 jest rowna 1.273
Suma dla x = 0.77 jest rowna 1.470