fork download
  1. #include <cmath>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. const unsigned int RESULTING_SEQUENCE_SIZE = 10;
  6.  
  7. int main() {
  8. double currentMember;
  9. double resultingSequence[RESULTING_SEQUENCE_SIZE]{0};
  10. // Process until the end of the input stream
  11. while (cin >> currentMember) {
  12. // Accumulate the sum of suitable elements to the corresponding member of the resulting sequence
  13. if (1 <= ceil(currentMember) && ceil(currentMember) <= RESULTING_SEQUENCE_SIZE) {
  14. resultingSequence[(int)ceil(currentMember) - 1] += currentMember;
  15. }
  16. }
  17. // Output the sequence
  18. for (auto currentMember : resultingSequence) {
  19. cout << currentMember << " ";
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3460KB
stdin
2.02 42 1.998 3 7.43 3.33 3.03 5.56 5 5.5
stdout
0 1.998 5.02 6.36 5 11.06 0 7.43 0 0