Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include<cstdlib>
  3. #include<ctime>
  4. using namespace std;
  5. const unsigned int MAX_N = 50;
  6. int main()
  7. {
  8.     int A[MAX_N];
  9.     int n;
  10.     int b, a;
  11.     int  ilosc_index = 0;
  12.     int pary = 0;
  13.     int j;
  14.     srand(time(NULL));
  15.     cout << "Podaj ilosc liczb: ";
  16.     cin >> n;
  17.     cout << "Podaj poczatek przedzialu a: ";
  18.     cin >> a;
  19.     cout << "Podaj kraniec przedzialu b: ";
  20.     cin >> b;
  21.     if (n > 0 && n < 50) {
  22.         for (int i = 0; i < n; i++) {
  23.             A[i] = rand() % (b - a) +a + 1;
  24.         }
  25.         cout << "A = [";
  26.         for (int i = 0; i < n; i++) {
  27.             cout <<" "<< A[i];
  28.            
  29.         }cout << " ]" << endl << endl;
  30.         for (int j = 0; j < n - 1; j++) {
  31.             if (abs(A[j] - A[j + 1]) >= 3)
  32. {
  33.                 pary++;
  34.             cout << "(" << A[j] << "," << A[j + 1] << ")"
  35.            If(A[j]> A[j+1]
  36. {
  37.            For (b =0; b< n ;n++)
  38. {
  39. If (A[b] == A[j])
  40. Cout<< "    " << b
  41. }
  42. }
  43.             Tutaj jeszcze dla A j < A j+1 potem Endo
  44.  
  45.         }
  46.  
  47.            
  48.     }
  49.     cout << "Ilosc par =" << pary << endl;
  50.     cout << "Ile indeksow" << ilosc_index;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement