Skip to content

Instantly share code, notes, and snippets.

@MikuroXina
Created May 21, 2023 02:59
Show Gist options
  • Select an option

  • Save MikuroXina/442ecd6a2efaef9815086d9883cabe30 to your computer and use it in GitHub Desktop.

Select an option

Save MikuroXina/442ecd6a2efaef9815086d9883cabe30 to your computer and use it in GitHub Desktop.
Outputting numbers with delimitting spaces in C++ for competitive programming.
#include <algorithm>
#include <iostream>
#include <numeric>
using namespace std;
int main() {
int nums[3];
for (auto &num: nums) {
cin >> num;
}
cout << accumulate(
begin(nums) + 1,
end(nums),
to_string(nums[0]),
[](string s0, int const& s1) {
return s0 += " " + to_string(s1);
}
) << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment