Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. /*fisier data.txt
  2.  
  3. 5
  4. 2
  5. 3
  6. 9
  7. 1
  8. 6
  9.  
  10. */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14.  
  15. int main()
  16. {
  17. int i,n,min=NULL,max=NULL,temp;
  18. FILE *f_in;
  19. f_in=fopen("data.txt","r");
  20. fscanf(f_in,"%d\n",&n);
  21. printf("Indice:%d\n",n);
  22. printf("---Note---\n");
  23. for(i=0;i<n;i++){
  24. fscanf(f_in,"%d",&temp);
  25. printf("%d\n",temp);
  26. if(min != NULL){
  27. if(temp<min){
  28. min=temp;
  29. }
  30. }else{
  31. min=temp;
  32. }
  33. if(min != NULL){
  34. if(temp>max){
  35. max=temp;
  36. }
  37. }else{
  38. max=temp;
  39. }
  40. }
  41. printf("Min=%d\nMax=%d\n",min,max);
  42. fclose(f_in);
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement