fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, k=0, S=0 , D=0, N=0;
  6. cin>>n;
  7. int a[n];
  8. for(int i=0; i<n; i++){
  9. cin>>a[i];
  10. if(a[i]<0){
  11. S+=a[i];
  12. }
  13. else if(a[i]=0){
  14. D+=a[i];
  15. }
  16. else if(a[i]>0){
  17. N+=a[i];
  18. }
  19. }
  20.  
  21. cout<<S<<" "<<D<<" "<<N<<" "<<endl;
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5284KB
stdin
10
-2 -3 0 5 10 3 4 0 -1 2

stdout
-6 0 0