Pancake numbers: Difference between revisions

Content added Content deleted
(Added Applesoft BASIC, BASIC256, Chipmunk Basic, Gambas, GW-BASIC, MSX Basic, PureBasic, QBasic, True BASIC and Yabasic)
m (Altered code to be more C++ idiomatic.)
Line 351:
=={{header|C++}}==
<syntaxhighlight lang="c++">
 
#include <iostream>
#include <vector>
Line 359 ⟶ 360:
#include <iomanip>
 
std::vector<int32_t> flip_stack(std::vector<int32_t>& stack, const int32_t index) {
reverse(stack.begin(), stack.begin() + index);
return stack;
}
 
std::pair<std::vector<int32_t>, int32_t> pancake(const int32_t number) {
std::vector<int32_t> initial_stack(number);
std::iota(initial_stack.begin(), initial_stack.end(), 1);
Line 396 ⟶ 397:
 
int main() {
for ( intint32_t n = 1; n <= 9; ++n ) {
std::pair<std::vector<int32_t>, int32_t> result = pancake(n);
std::cout << "pancake(" << n << ") = " << std::setw(2) << result.second << ". Example [";