Advertisement
Shiny_

Untitled

Apr 5th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <stdarg.h>
  2. #include <stdio.h>
  3.  
  4. #define program(arguments) void main(void) {arguments;}
  5. #define calculate(...) (calculate__(sizeof((int[]){__VA_ARGS__})/sizeof(int), __VA_ARGS__))
  6.  
  7. int calculate__(int number, ...) {
  8.     int sum = 0;
  9.     va_list arguments;
  10.     va_start(arguments, number);
  11.    
  12.     for(int i = 0; i < number; i++) {
  13.         sum += va_arg(arguments, int);
  14.     }
  15.    
  16.     va_end(arguments);
  17.     return printf("%d", sum);
  18. }
  19.  
  20. #define __calculate calculate__
  21. #define _calculate calculate__
  22.  
  23. typedef int * pointer_int;
  24. typedef void * pointer_void;
  25. typedef char * pointer_char;
  26.  
  27. program (
  28.     pointer_int i = 0;
  29.     printf("%d", i, "%d", calculate(1 * 2 - 3 + 4 / 5))
  30. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement