Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int n,i,nr,s,v[201];
  5. int main()
  6. {
  7. cin>>n;
  8. for(i=1;i<=n;i++)
  9. {
  10. cin>>v[i]; //citirea vectorului
  11. if(v[i]!=0)
  12. {
  13. s=s+v[i]; //suma nenulelor
  14. nr++; //cate nr
  15. }
  16. }
  17. for(i=1;i<=n;i++)
  18. {
  19. if(v[i]==0)
  20. v[i]=s/nr; //inlocuirea nulelor
  21. cout<<v[i]<<" "; //afisare
  22. }
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement