monoteen

C Chapter.10_ 20

Nov 10th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. int GetMin_Max(int *a)
  3. {
  4.     int x,b,c;
  5.     for(x=0;x<5;x++)
  6.     {
  7.           if(x==0 || *(a+x)>b)
  8.           {
  9.                 b=*(a+x);
  10.           }
  11.           if(x==0 || *(a+x)<c)
  12.           {
  13.                 c=*(a+x);
  14.           }
  15.     }
  16.     printf("최대값: %d, 최소값: %d\n",b,c);
  17.     return 0;
  18. }
  19. int main (void)
  20. {
  21.     int m;
  22.     int a[5];
  23.     printf("정수 5개를 입력하세요.\n");
  24.     for(m=0;m<5;m++)
  25.     {
  26.           scanf("%d",&a[m]);
  27.     }
  28.     GetMin_Max(a);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment