Guest User

Untitled

a guest
Jan 20th, 2020
108
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f("date.in");
  5. ofstream g("date.out");
  6. int n,i,max1,min1,a[1000],s;
  7. float media;
  8. void numere (int & max1, int & min1, float & media)
  9. {
  10.  
  11. for(i=0;i<n-1;i++)
  12. {
  13. if(a[i]>a[i+1])
  14. max1=i;
  15. if(a[i]<a[i+1])
  16. min1=i;
  17. s+=a[i];
  18. }
  19. s+=a[n-1];
  20. media = (float)s/n;
  21. cout<<a[max1]<<" "<<a[min1]<<" "<<media;
  22. }
  23. int main()
  24.  
  25. {
  26. f>>n;
  27. for(i=0;i<n;i++)
  28. f>>a[i];
  29. max1=0;
  30. min1=0;
  31. s=0;
  32. media=0;
  33. numere(max1,min1,media);
  34.  
  35.  
  36. return 0;
  37. }
RAW Paste Data