Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include<iostream> //Marcin Matliński
  2. using namespace std;
  3.  
  4.  
  5. int silnia(int n)
  6. {
  7.     if (n == 0)return 1;
  8.     return silnia(n - 1)*n;
  9. }
  10. double pierwiastki(double a,double b,double c)
  11. {
  12.     double delta = b*b - 4.0*a*c;
  13.     if (delta > 0.0)
  14.     {
  15.         delta = sqrt(delta);
  16.         cout<< "x1 ="<< (-b + delta) / (2.0*a)<<endl;
  17.         cout<< "x2 ="<< (-b - delta) / (2.0*a)<<endl;
  18.     }
  19.     else if (delta == 0.0)
  20.     {
  21.         cout << "x0 ="<< (- b / (2.0*a)) << endl;
  22.     }
  23.     else
  24.     {
  25.         cout << "Brak rozwiązań\n";
  26.     }
  27.     return 0;
  28.  
  29. }
  30. int Fibonacci(int n)
  31. {
  32.     if (n < 3)return 1;
  33.     return (Fibonacci(n - 2) + Fibonacci(n - 1));
  34. }
  35. void napis()
  36. {
  37.     char napis[100];
  38.     for (i = 0; i < ; i++)
  39.     {
  40.      cout<<napis[0]<<napis[0]
  41.     }
  42. }
  43. int main()
  44. {
  45.     int n,x;
  46.     double a,b,c;
  47.     cout << "Podaj numer silni\n";
  48.     cin >> n;
  49.     cout << silnia(n) << endl;
  50.     cout << "Podaj a,b,c"<<endl;
  51.     cin >> a>> b>> c;
  52.     cout << pierwiastki(a, b, c) << endl;
  53.     cout << "Podaj numer ciągu Fibonacciego "<<endl;
  54.     cin >> x;
  55.     cout << Fibonacci(x) << endl;
  56.     return 0;
  57.    
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement