Ad
  • Custom User Avatar

    what it wants from me?

    It is theoretically possible that your code will go through your function without doing any return, and C++ does not like this. It is not possible in this challenge because all inputs are guaranteed to have a valid answer, but C++ compiler does not know this, and it needs to have a return at every path. You can fix it by adding return 0; at the end of your function.

    how can i fully understand a problem with my code if it doesn't show me the full vector?

    You can use std::cout in your solution and print the vector to the console, but I agree this can be tedious in C++. Ideally, tests would show the vector, but they don't.

    But even when you add missing return, and when you check the vector, and you will try to reproduce the error, it is possible that your code will work for you. The bug in your code can be subtle and difficult to debug, and it's caused by out of bounds access: sometimes, your code accesses invalid memory before the vector, and sometimes after the vector, and this can be a bug difficult to reproduce.

  • Custom User Avatar

    I don't understand what it wants from me??? ./solution.cpp:10:1: warning: control may reach end of non-void function [-Wreturn-type]. And next question - how can i fully understand a problem with my code if it doesn't show me the full vector? Wrong answer for 5 elements!
    Expected: equal to 0.55
    Actual: 1