Advertisement
Vxzyd

Kolokwium 1

Jan 13th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.32 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4. #include <cstdlib>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. void sortuj1 (double &x, double &y)
  10. {
  11.     if (x<y)
  12.     {
  13.         double z=y;
  14.         y=x;
  15.         x=z;
  16.     }
  17. }
  18.  
  19. void sortuj (int *tab,int N)
  20. {
  21.     int x=0;
  22.     for(int i=0; i<N; i++)
  23.     {
  24.         for (int j=0; j<N; j++)
  25.         {
  26.             if (tab[i]<tab[j])
  27.             {
  28.                 x=tab[i];
  29.                 tab[i]=tab[j];
  30.                 tab[j]=x;
  31.             }
  32.         }
  33.     }
  34. }
  35.  
  36. void wypisz (int tab[], int N)
  37. {
  38.     for (int i=0; i<N; i++)
  39.     {
  40.         cout << "Tab [ " << i+1 <<" ] : " << tab[i] << endl;
  41.     }
  42. }
  43.  
  44.  
  45.  
  46. int main()
  47. {
  48.     /*
  49.   int x=0;
  50.   cout << "Podaj dlugosc kreski do wciongniecia hehe: " << endl;
  51.   cin >> x;
  52.  
  53.   for (int i=0; i<x ; i++)
  54.   {
  55.       cout << "|\n";
  56.   }
  57.     */
  58.     /*
  59.     double A=0, B=0, C=0;
  60.  
  61.     double suma=0, iloczyn=0, srednia=0, potega=0;
  62.  
  63.     cout << "Podaj 3 liczby: " << endl;
  64.     cout << "A: ";
  65.     cin >> A;
  66.     cout << "B: ";
  67.     cin >> B;
  68.     cout << "C: ";
  69.     cin >> C;
  70.  
  71.     suma=A+B+C;
  72.     iloczyn=A*B*C;
  73.     srednia=(A+B+C)/3;
  74.     potega=pow(A,B);
  75.  
  76.     cout << "Suma: : " << suma << endl;
  77.     cout << "Srednia : " << srednia << endl;
  78.     cout << "Potega : " << potega << endl;
  79.     */
  80.     /*
  81.     double a=0;
  82.     double b=0;
  83.     cout << "Podaj 2 liczby: " << endl;
  84.     cout << "a = ";
  85.     cin >> a;
  86.     cout << "b = ";
  87.     cin >> b;
  88.     sortuj1 (a,b);
  89.  
  90.     cout << "a i b posortowane od najwiekszej do najmniejszej to : " << a << " " << b;
  91.     */
  92.     /*
  93.     int x=0;
  94.     cin >> x;
  95.     for (int i=0; i<x; i++)
  96.     {
  97.         cout << setw(i+1);
  98.         for (int j=0; j<(2*(x-i)-1) ; j++)
  99.         {
  100.             cout << "*";
  101.         }
  102.         cout << endl;
  103.     */
  104.     /*
  105.     int x=0;
  106.     cin >> x;
  107.     for (int i=0; i<x; i++)
  108.     {
  109.         cout << setw(x-i);
  110.         for (int j=0; j<(2*i+1) ; j++)
  111.         {
  112.             cout << "*";
  113.         }
  114.         cout << endl;
  115.     }
  116.     */
  117.     /*
  118.     int N=0;
  119.     int *tab;
  120.     cout << "Ile liczb wprowadzic do tablicy? " << endl;
  121.     cin >> N;
  122.     tab= new int [N];
  123.  
  124.     for (int i=0; i<N; i++)
  125.     {
  126.         cout << "Tab [ " << i+1 << " ] :";
  127.         cin >> tab [i] ;
  128.     }
  129.  
  130.     sortuj (tab, N);
  131.     wypisz (tab, N);
  132.     */
  133.    
  134.     return 0;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement