Advertisement
NoxScourge

Untitled

Aug 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. void main() {
  5.  
  6.  
  7. int br;
  8. int prosecnavrednost = 0;
  9. int n = 0;
  10. int suma = 0;
  11. FILE *f ,*fp;
  12.  
  13. f = fopen("C:\\Users\\Nox Scourge\\Desktop\\brojevi1.txt", "r");
  14. fp = fopen("C:\\Users\\Nox Scourge\\Desktop\\pros.txt", "w");
  15. while (!feof(f)) {
  16.  
  17.  
  18.  
  19. fscanf(f, "%d\n", &br);
  20. n++;
  21. suma += br;
  22.  
  23.  
  24. fprintf(fp, "%d\n", prosecnavrednost = suma / n);
  25.  
  26. }
  27.  
  28. fclose (f);
  29. fclose(fp);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement