Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "time.h"
- using namespace std;
- double fmax(int r, ...)
- {
- int i, max, *f;
- double max1, *fd;
- int n = *(&r + 1);
- max = -999;
- max1 = -999;
- if (r == 0)
- {
- f = &r + 2;
- for (i = 0; i < n; i++)
- {
- if (*(f + i) > max) max = *(f + i);
- }
- return max;
- }
- if (r == 1)
- {
- fd = (double *)(&r + 2);
- for (i = 0; i < n; i++)
- {
- if (*(fd + i) > max1) max1 = *(fd + i);
- }
- return max1;
- }
- return 0;
- }
- int main()
- {
- setlocale(LC_CTYPE, "Rus");
- srand((unsigned)time(NULL));
- int i, a[15];
- double b[10], bb, cc, c[5];
- cout << "Массив int:\n";
- for (i = 0; i < 15; i++)
- {
- a[i] = rand() % 99 - rand() % 99;
- cout << a[i] << ' ';
- }
- cout << "\n\nМассив double:\n";
- for (i = 0; i < 10; i++)
- {
- bb = ((rand() % 10000 + 1) / (rand() % 10 + 1));
- b[i] = rand() % 99 - rand() % 99 + bb/100;
- cout << b[i] << " ";
- }
- cout << "\n\n2 массив double:\n";
- for (i = 0; i < 5; i++)
- {
- cc = ((rand() % 100000 + 1) / (rand() % 10 + 1));
- c[i] = rand() % 99 - rand() % 99 + cc / 10000;
- cout << c[i] << " ";
- }
- cout << "\n\nmax в int: " << fmax(0, 15, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14]);
- cout << "\nmax в double: " << fmax(1, 10, b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9]);
- cout << "\nmax в double 2: " << fmax(1, 5, c[0], c[1], c[2], c[3], c[4]) << '\n';
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement