Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include<iostream.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5. int i,n,np = 0,nn = 0,a[25];
  6. float poz = 0, neg = 0;
  7. cout<<"Dati macar o valoare negativa!!!"<<endl<<endl;
  8. cout<<"n=";cin>>n;
  9. for(i=0;i<n;i++)
  10. {
  11. cout<<"a["<<i+1<<"]=";cin>>a[i];
  12. if (a[i] > 0){
  13. poz=poz+a[i];np++;}
  14. else
  15. {neg=neg+a[i];nn++;}
  16. }
  17. poz=poz/np;
  18. neg=neg/nn;
  19. cout<<"Media aritmetica pozitiva este "<<poz<<endl;
  20. cout<<"Media aritmetica negative este "<<neg;
  21. getch();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement