Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*fisier data.txt
- 5
- 2
- 3
- 9
- 1
- 6
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int i,n,min=NULL,max=NULL,temp;
- FILE *f_in;
- f_in=fopen("data.txt","r");
- fscanf(f_in,"%d\n",&n);
- printf("Indice:%d\n",n);
- printf("---Note---\n");
- for(i=0;i<n;i++){
- fscanf(f_in,"%d",&temp);
- printf("%d\n",temp);
- if(min != NULL){
- if(temp<min){
- min=temp;
- }
- }else{
- min=temp;
- }
- if(min != NULL){
- if(temp>max){
- max=temp;
- }
- }else{
- max=temp;
- }
- }
- printf("Min=%d\nMax=%d\n",min,max);
- fclose(f_in);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement