Advertisement
hamaXD

อีเปียว v2

Oct 4th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.48 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define NUM 5
  5. int* max(int* a, int *b);
  6.  
  7. int main(){
  8.   int i,*num_max;
  9.   int *x;
  10.    x = (int *) malloc(sizeof(int)*NUM);
  11.   for(i = 0; i < 5; i++){
  12.         scanf("%d",&*(x+i));
  13.   }
  14.   num_max = max(x, (x+NUM)) ;
  15.   printf("=%d\n",*num_max );
  16.   return 0;
  17. }
  18.  
  19. int* max(int *a, int *b){
  20.     int i,*NUMMAX ;
  21.     *NUMMAX = *a;
  22.     for(i=0;i<NUM;i++){
  23.        
  24.         if(*NUMMAX <*(a+i)){
  25.             *NUMMAX=*(a+i);
  26.         }
  27.     }
  28.    
  29.     //printf("%d\n",*NUMMAX);
  30.     return NUMMAX;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement