Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- double numGenerator(int i, float x) {
- float r;
- //r = (pow(-1, i)*log(1 + x * x)) / sqrt(1 + x * x);
- r = (pow(-1, i)*sin(1 + x + x * x)) / (1 + x * x);
- return r;
- }
- void bubbleSort(float y[], int N) {
- double t = 0;
- for (int i = 0; i < N; i++) {
- for (int j = N - 1; j >= (i + 1); j--) {
- if (y[j] >= y[j - 1]) {
- t = y[j];
- y[j] = y[j - 1];
- y[j - 1] = t;
- }
- }
- }
- }
- int main()
- {
- int N,k;
- cout << "Enter n: "; cin >>N;
- float *y = new float[N];
- cout << "Enter x: "; cin >> k;
- y[0] = numGenerator(0, k);
- for (int i = 1; i < N; i++)
- y[i] = numGenerator(i, y[i - 1]);
- for (int i = 0; i < N; i++)
- cout << y[i] << ' ';
- cout << endl;
- bubbleSort(y, N);
- for (int i = 0; i < N; i++) {
- cout << y[i] << ' ';
- }
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement