daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Nov 14th, 2018 71 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdarg.h>
  4. enum type { Int, Double,End };
  5. void max(...) {
  6.     type type;
  7.     int intsum = 0;
  8.     double doublesum = 0;
  9.     int i;
  10.     va_list z;
  11.     va_start(z, type);
  12.         while ((type  = va_arg(z,type)) != End)
  13.             if (type == Int) {
  14.             int value = va_arg(z, int);
  15.             intsum += value;
  16.         }
  17.         while ((type = va_arg(z,type)) != End)
  18.             if (type == Double){
  19.             double value = va_arg(z, double);
  20.             doublesum += value;
  21.         }
  22.     printf("%d\n", intsum);
  23.     printf("%f\n",doublesum);
  24.     va_end(z);
  25. }
  26. int main() {
  27.     max(Int,5,7,1,7,3,4,5,End);
  28.     max(Double,5.12,6.66,7.77,8.88,9,78,End);
  29.     return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top