Advertisement
Matrxi999

Untitled

Jan 27th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     srand(time(NULL));
  10.     const int N = 1000;
  11.  
  12.     int P[N];
  13.     double A[N];
  14.  
  15.     for (int i=0; i<=N; i++)
  16.         P[i]= 1+rand()%100;
  17.  
  18.    for (int i=0; i<=N; i++)
  19.        cout << P[i] << endl;
  20.    cout << endl;
  21.  
  22.    for (int i=0;i<=N-1;i++)
  23.    {
  24.        int i_min = i;
  25.        for (int j=i+1; j<=N; j++)
  26.            if (P[j] < P[i_min])
  27.                i_min=j;
  28.  
  29.        int schowek = P[i];
  30.        P[i] = P[i_min];
  31.        P[i_min] = schowek;
  32.    }
  33.  
  34.    cout << "po posortowaniu: " << endl;;
  35.  
  36.    for (int i=0; i<=N; i++)
  37.        cout << P[i] << endl;
  38.    cout << endl;
  39.  
  40.  
  41.    for (int i=0; i<=N; i++)
  42.        A[i] = sqrt(P[i]);
  43.  
  44.    for (int i=0; i<=N; i++)
  45.        cout << A[i] << '\t';
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement