53 lines
905 B
C++
53 lines
905 B
C++
|
|
//Program Permutation
|
|||
|
|
//Backtacking (Variable anzahl von ineinander geschachtelten Schleifen
|
|||
|
|
|
|||
|
|
#include <stdio.h>
|
|||
|
|
#include <iostream.h>
|
|||
|
|
|
|||
|
|
//#define DEBUG
|
|||
|
|
|
|||
|
|
int n=20; // Anzahl Schleifen
|
|||
|
|
|
|||
|
|
char Feld[100];
|
|||
|
|
char anfang,ende;
|
|||
|
|
|
|||
|
|
void ForS(int Ebene)
|
|||
|
|
{
|
|||
|
|
char i;
|
|||
|
|
int k;
|
|||
|
|
|
|||
|
|
if (Ebene <= n-1)
|
|||
|
|
for(i=anfang;i <= ende; i++)
|
|||
|
|
{
|
|||
|
|
Feld[Ebene] = i;
|
|||
|
|
#ifdef DEBUG
|
|||
|
|
cout << "\nAufruf mit ebene(stelle):" << Ebene << " Wert:" << i;
|
|||
|
|
#endif
|
|||
|
|
ForS(Ebene+1);
|
|||
|
|
#ifdef DEBUG
|
|||
|
|
cout << "\nzur<EFBFBD>ck mit ebene(stelle):" << Ebene << " Wert:" << i;
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
for(k=0;k<=n-2;k++)
|
|||
|
|
cout << Feld[k] ;
|
|||
|
|
cout << Feld[n-1] << endl;
|
|||
|
|
#ifdef DEBUG
|
|||
|
|
cout << "\nKKK";
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void main(void)
|
|||
|
|
{
|
|||
|
|
cout << "Wieviele Schleifen sollen geschachtelt werden (max.100):";
|
|||
|
|
cin >> n;
|
|||
|
|
cout << "Anfangen bei:";
|
|||
|
|
cin >> anfang;
|
|||
|
|
cout << "Ende bei:";
|
|||
|
|
cin >> ende;
|
|||
|
|
cout << endl;
|
|||
|
|
ForS(0);
|
|||
|
|
}
|