Advertisement
rotti321

probleme cu siruri de numere

Mar 4th, 2022
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, a[1001],maxx=0,minn=99999999,sum=0; ///max 1000 de elemente
  7. double medie;
  8. cin>>n;
  9. for(int i=1;i<=n;i++){
  10. cin>>a[i];
  11. if(a[i]>maxx){
  12. maxx=a[i];
  13. }
  14. }
  15. cout<<maxx;
  16. for(int i=1;i<=n;i++){
  17. if(a[i]<minn){
  18. minn=a[i];
  19. }
  20.  
  21. }
  22. cout<<endl;
  23. cout<<minn;
  24. for(int i=1;i<=n;i++){
  25. sum=a[i]+sum;
  26. }
  27. cout<<endl;
  28. cout<<sum;
  29. medie = 1.0*sum /n;
  30. cout<<endl<<medie;
  31. return 0;
  32. }
Advertisement
RAW Paste Data Copied
Advertisement