#include <iostream>
using namespace std;
class class1
{
public:
int n;
double* arr = new double[n];
void get();
void sort_ascend();
void display();
};
void class1::get()
{
cout << "Enter the number of elements in the array: ";
cin >> n;
cout << "Enter the elements one by one: ";
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
}
void class1::sort_ascend()
{
for (int j = 0; j < n - 1; j++)
{
for (int k = j + 1; k < n; k++)
{
if (arr[j] > arr[k])
{
int t;
t = arr[j];
arr[j] = arr[k];
arr[k] = t;
}
}
}
}
void class1::display()
{
cout << "The array after sorting in ascending order is: {";
for (int i = 0; i < n; i++)
{
cout << arr[i];
if (i != n - 1)
{
cout << ", ";
}
}
cout << "}";
}
int main()
{
class1 a;
a.get();
a.sort_ascend();
a.display();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgY2xhc3MxCnsKcHVibGljOgoJaW50IG47Cglkb3VibGUqIGFyciA9IG5ldyBkb3VibGVbbl07Cgl2b2lkIGdldCgpOwoJdm9pZCBzb3J0X2FzY2VuZCgpOwoJdm9pZCBkaXNwbGF5KCk7Cn07Cgp2b2lkIGNsYXNzMTo6Z2V0KCkKewoJY291dCA8PCAiRW50ZXIgdGhlIG51bWJlciBvZiBlbGVtZW50cyBpbiB0aGUgYXJyYXk6ICI7CgljaW4gPj4gbjsKCWNvdXQgPDwgIkVudGVyIHRoZSBlbGVtZW50cyBvbmUgYnkgb25lOiAiOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCgl7CgkJY2luID4+IGFycltpXTsKCX0KfQoKdm9pZCBjbGFzczE6OnNvcnRfYXNjZW5kKCkKewoJZm9yIChpbnQgaiA9IDA7IGogPCBuIC0gMTsgaisrKQoJewoJCWZvciAoaW50IGsgPSBqICsgMTsgayA8IG47IGsrKykKCQl7CgkJCWlmIChhcnJbal0gPiBhcnJba10pCgkJCXsKCQkJCWludCB0OwoJCQkJdCA9IGFycltqXTsKCQkJCWFycltqXSA9IGF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