Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdarg.h>
- enum type { Int, Double,End };
- void max(...) {
- type type;
- int intsum = 0;
- double doublesum = 0;
- int i;
- va_list z;
- va_start(z, type);
- while ((type = va_arg(z,type)) != End)
- if (type == Int) {
- int value = va_arg(z, int);
- intsum += value;
- }
- while ((type = va_arg(z,type)) != End)
- if (type == Double){
- double value = va_arg(z, double);
- doublesum += value;
- }
- printf("%d\n", intsum);
- printf("%f\n",doublesum);
- va_end(z);
- }
- int main() {
- max(Int,5,7,1,7,3,4,5,End);
- max(Double,5.12,6.66,7.77,8.88,9,78,End);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement