Code:
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
int main () {
int P [] = { 1, 1, 1, 1, 1, 1, 1};
int ka [] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0};
int L, H, z, f, y, x, p, k, a, c;
string line;
z=6; p = 0;
ofstream myfile ("Factorial.txt"); if (myfile.is_open())
cout << "Please type the highest number: ";cin >> L; ++L;
loop: y=z; while (P [z] != L) {
H = 0; a = z; c = (z-1); f = 21;
ka[1] = (P[1]-P[0]);
ka[2] = (P[2]-P[0]);
ka[3] = (P[3]-P[0]);
ka[4] = (P[4]-P[0]);
ka[5] = (P[5]-P[0]);
ka[6] = (P[6]-P[0]);
ka[7] = (P[2]-P[1]);
ka[8] = (P[3]-P[1]);
ka[9] = (P[4]-P[1]);
ka[10] = (P[5]-P[1]);
ka[11] = (P[6]-P[1]);
ka[12] = (P[3]-P[2]);
ka[13] = (P[4]-P[2]);
ka[14] = (P[5]-P[2]);
ka[15] = (P[6]-P[2]);
ka[16] = (P[4]-P[3]);
ka[17] = (P[5]-P[3]);
ka[18] = (P[6]-P[3]);
ka[19] = (P[5]-P[4]);
ka[20] = (P[6]-P[4]);
ka[21] = (P[6]-P[5]);
while ( ka[f] != 0 ) { if (ka[f] == 0) {++H, --f;} else --f; }
while ( c != -1) { if (P[a] <= P[c]) {++H, --a, --c;} else {--a, --c;} }
if (H == 0) {myfile << P[0] << "\t" << P[1] << "\t" << P[2] << "\t" << P[3] << "\t" << P[4] << "\t" << P[5] << "\t" << P[6] << "\n";};
if (k != 0) {++P [z], p = 0;} else p = 0; }; while (y != 0)
if ( P [y] != L) goto endloop; else P [y]=1, --y, ++P [y]; goto endloop;
endloop: while (P[0] != L) {goto loop;} myfile.close(); return 0;}