We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
intsum(intcount,...){// initialize // 1. va_list args;// 2. va_start(args, count); pass in the number of the arguments.va_listargs;va_start(args,count);intres=0;for(inti=0;i<count;i++){res+=va_arg(args,int);}va_end(args);returnres;}intmin(intcount,...){va_listargs;va_start(args,count);intmin_int=va_arg(args,int);for(inti=1;i<count;i++){inttemp=va_arg(args,int);if(temp<min_int){min_int=temp;}}va_end(args);returnmin_int;}intmax(intcount,...){va_listargs;va_start(args,count);intmax_int=va_arg(args,int);for(inti=1;i<count;i++){inttemp=va_arg(args,int);if(temp>max_int){max_int=temp;}}va_end(args);returnmax_int;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Variadic functions in C
You are viewing a single comment's thread. Return to all comments →