Advertisement
obernardovieira

O maior numero

Mar 14th, 2013
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.81 KB | None | 0 0
  1. /*
  2.  ============================================================================
  3.  Name        : maiornumero.c
  4.  Author      : obernardovieira
  5.  Version     :
  6.  Copyright   : copyright-obernardovieira
  7.  Description : Hello World in C, Ansi-style
  8.  ============================================================================
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <stdarg.h>
  14.  
  15. int maiornum(int n,...);
  16. int main(void) {
  17.     puts("Maior numero"); /* prints Maior numero */
  18.     int maior;
  19.     maior=maiornum(6,15,23,75,11,14,12);
  20.     printf("maior - %d",maior);
  21.     return EXIT_SUCCESS;
  22. }
  23. int maiornum(int n,...) {
  24.     int i;
  25.     int maiorn=0;
  26.     int an=0;
  27.     va_list listanum;
  28.     va_start(listanum,n);
  29.     for(i = 0; i < n; i++) {
  30.         an=va_arg(listanum,int);
  31.         if(maiorn<an) {
  32.             maiorn=an;
  33.         }
  34.     }
  35.     return maiorn;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement