Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<cstdlib>
- #include<ctime>
- using namespace std;
- const unsigned int MAX_N = 50;
- int main()
- {
- int A[MAX_N];
- int n;
- int b, a;
- int ilosc_index = 0;
- int pary = 0;
- int j;
- srand(time(NULL));
- cout << "Podaj ilosc liczb: ";
- cin >> n;
- cout << "Podaj poczatek przedzialu a: ";
- cin >> a;
- cout << "Podaj kraniec przedzialu b: ";
- cin >> b;
- if (n > 0 && n < 50) {
- for (int i = 0; i < n; i++) {
- A[i] = rand() % (b - a) +a + 1;
- }
- cout << "A = [";
- for (int i = 0; i < n; i++) {
- cout <<" "<< A[i];
- }cout << " ]" << endl << endl;
- for (int j = 0; j < n - 1; j++) {
- if (abs(A[j] - A[j + 1]) >= 3)
- {
- pary++;
- cout << "(" << A[j] << "," << A[j + 1] << ")"
- If(A[j]> A[j+1]
- {
- For (b =0; b< n ;n++)
- {
- If (A[b] == A[j])
- Cout<< " " << b
- }
- }
- Tutaj jeszcze dla A j < A j+1 potem Endo
- }
- }
- cout << "Ilosc par =" << pary << endl;
- cout << "Ile indeksow" << ilosc_index;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement