Advertisement
Guest User

takietam

a guest
Oct 16th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <math.h>
  4. #include <windows.h>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. int silnia(int liczba)
  10.  
  11. {
  12.  
  13.     long long silnia = 1;
  14.     for (int i = 1; i<=liczba;i++)
  15.     silnia *= i;
  16.     return silnia;
  17.  
  18. }
  19. /*
  20. int rownanie(double delta)
  21.  
  22. {
  23.     double x1,a,b,c,x2;
  24.  
  25.     if (delta<0)
  26.     {
  27.         cout << "Brak pierwiastkow rownania!" << endl;
  28.     }
  29.     else if (delta=0)
  30.     {
  31.         cout << "Rownanie posiada jeden pierwiastek: " << x1=((-b)/(2*a)) << endl;
  32.     }
  33.     else
  34.     {
  35.         cout << "Rownanie posiada dwa pierwiastki: " << x1= (-b+sqrt(delta))/(2*a) << " oraz " << x2=(-b-sqrt(delta))/(2*a) << endl;
  36.     }
  37.     return("PAUSE");
  38.  
  39. }
  40. */
  41.  
  42. int fib(int n)
  43. {
  44.     if(n == 0) return 0;
  45.     if(n == 1) return 1;
  46.     return fib(n-1)+fib(n-2);
  47. }
  48.  
  49. void pisz(string n)
  50. {
  51.     for(int i=0; i<n.size(); i++)
  52.     {
  53.         cout<<n[i];
  54.         cout<<n[i];
  55.         Sleep(100);
  56.     }
  57. }
  58.  
  59.  
  60. void wspak(string txt)
  61. {
  62.      cout<<"Wspak:\n";
  63.      for(int i=txt.length()-1;i>=0;i--)
  64.         cout<<txt[i];
  65. }
  66.  
  67.  
  68.    int main()
  69. {
  70.  
  71.     int liczba;
  72.     cout << "Podaj liczbe ktorej silnie chcesz obliczyc: " << endl;
  73.     cin >> liczba;
  74.     cout << silnia(liczba) << endl;
  75.  
  76.  
  77.  
  78. /*
  79.     double a,b,c,x1,x2,delta;
  80.     cout << "Podaj wspolczynniki rownania: a*x^2+b*x+c: " << endl;
  81.     cout << "a= " << endl;
  82.     cin >> a;
  83.     cout << "b= " << endl;
  84.     cin >> b;
  85.     cout << "c= " << endl;
  86.     cin >> c;
  87.     delta = b * b - 4 * a * c;
  88.     cout << rownanie(delta) << endl;
  89.     return(0
  90. */
  91.  
  92.     int n;
  93.     cout << "Podaj numer wyrazu ciagu fibonacciego do obliczenia:" << endl;
  94.     cin >> n;
  95.     cout << fib(n) << endl;
  96.     system("PAUSE");
  97.  
  98.  
  99.  
  100.  
  101.  
  102.     cout << "Napisz tekst ktory mam wypisac z powtorzonymi znakami: " << endl;
  103.     string napis;
  104.     cin >> napis;
  105.     pisz(napis);
  106.  
  107.     cout << " " << endl;
  108.  
  109.  
  110.     /*
  111.     cout << "Napisz tekst do wypisania ilosci liter: " << endl;
  112.     string napis;
  113.     cin >> napis;
  114. */
  115.  
  116.  
  117.     int argc;
  118.     char *argv[];
  119.  
  120.     string text;
  121.     cout<<"Podaj tekst: " << endl;
  122.     getline(cin, text);
  123.     wspak(text);
  124.     cout<<"\n";
  125.     system("PAUSE");
  126.     return EXIT_SUCCESS;
  127.  
  128.  
  129.  
  130.     return 0;
  131.  
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement