Advertisement
Evgeniy175

Untitled

Dec 21st, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. double fmax(int r,...)
  4. {
  5.     int i, max, *f;
  6.     double max1, *fd;
  7.     int n = *(&r + 1);
  8.     max = -999;
  9.     max1 = -999;
  10.     if (r == 0)
  11.     {
  12.         f = &r + 2;
  13.         for (i = 0; i < n; i++)
  14.         {
  15.             if (*(f + i) > max) max = *(f + i);
  16.         }
  17.         return max;
  18.     }
  19.     if (r == 1)
  20.     {
  21.         fd = (double *)(&r + 2);
  22.         for (i = 0; i < n; i++)
  23.         {
  24.             if (*(fd + i) > max1) max1 = *(fd + i);
  25.         }
  26.         return max1;
  27.     }
  28.     return 0;
  29. }
  30. int main()
  31. {
  32.     setlocale(LC_CTYPE, "Rus");
  33.     double r;
  34.     cout << "max в int: " << fmax(0, 14, 4, 5, 15, 2, 6, 5, 3, 43, 3, 2, 6, 8, 5, 1) << '\n';
  35.     cout << "max в double: " << fmax(1, 8, 3.7531, 5.3976, 0.1718, 1.9394, 2.2336, 88.1811, 43.1332, 36.4872) << '\n';
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement