Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- int main(int argc, char* argv[])
- {
- int n;
- double min;
- double max;
- cout << "Vvedit kilkist elementiv massiva";
- cin >> n;
- float* ptrarray = new float[n];
- for (int count = 0; count < n; count++) {
- ptrarray[count] = (rand() % 10 + 1) / float((rand() % 10 + 1));
- }
- min = ptrarray[0];
- max = ptrarray[0];
- cout << "array = ";
- for (int count = 0; count < n; count++) {
- if (min > ptrarray[count]) {
- min = ptrarray[count];
- }
- if (max < ptrarray[count]) {
- max = ptrarray[count];
- }
- if (ptrarray[count] > min * 1.5 && ptrarray[count] < max * 0.5) {
- cout << setprecision(2) << ptrarray[count] << " ";
- }
- }
- cout << endl << "min " << min << " max " << max << endl;
- delete[] ptrarray;
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement