Advertisement
kk258966

9/19 進階程式設計上課程式 練習二

Sep 19th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int main(void)
  4. {
  5.     int b,count=1;
  6.     int max=0,min=9999;
  7.     int no[10];
  8.     FILE *read;
  9.     read=fopen("input.txt","r");
  10.    
  11.     while((fscanf(read,"%d",&b))!=EOF)  
  12.     {
  13.           no[count]=b;
  14.           if(b>max)
  15.           max=b;
  16.           if(b<min)
  17.           min=b;
  18.           count++;
  19.          
  20.     }
  21.    
  22.     int i;
  23.     for(i=1;i<count;i++)
  24.     {
  25.        printf("%d\n",no[i]);
  26.                      
  27.     }
  28.     printf("min=%d /n max=%d",min,max);
  29.    
  30.     fclose(read);
  31.      
  32.    
  33.  
  34.     system("pause");
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement