Created
May 21, 2023 02:59
-
-
Save MikuroXina/442ecd6a2efaef9815086d9883cabe30 to your computer and use it in GitHub Desktop.
Outputting numbers with delimitting spaces in C++ for competitive programming.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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