fork(9) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, k=0; double S=0;
  6. cin >> n;
  7. double C[n];
  8. for(int i=0; i<n; i++)
  9. {
  10. cin >> C[i];
  11. if (C[i]<0)
  12. k++;
  13. else S+=C[i];
  14. }
  15. cout << "Negative numbers: " << k << " The sum of positive numbers: " << S;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3476KB
stdin
14
1 2 -4.2 3.5 6.2 8 11 -144 288 9.2 -22 12 -13.5 14
stdout
Negative numbers: 4  The sum of positive numbers: 354.9