Advertisement
FazEN

Untitled

Oct 1st, 2022
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. int main() {
  5.  
  6. int a[20];
  7. float max_ar=0;
  8. float c=0,s=0;
  9. for (int i = 0; i < 20; ++i)
  10. {
  11. a[i]=rand()%(50+50+1)-50;
  12. if (a[i]<0)
  13. {
  14. s+=a[i];
  15. c+=1;
  16. }else if(abs(s)/c>max_ar || max_ar==0)
  17. {
  18. max_ar=abs(s)/c;
  19. c=0;
  20. s=0;
  21. }
  22. }
  23. printf("Ishodny massiv: ");
  24. for (int i = 0; i <20 ; ++i) printf("%d ",a[i]);
  25.  
  26. printf("\n%f",max_ar);
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement