41 lines
622 B
C++
41 lines
622 B
C++
|
|
//Program Permutation
|
||
|
|
//Backtacking (Variable anzahl von ineinander geschachtelten Schleifen
|
||
|
|
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <iostream.h>
|
||
|
|
|
||
|
|
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;
|
||
|
|
ForS(Ebene+1);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
for(k=0;k<=n-1;k++){
|
||
|
|
cout << Feld[k] ;
|
||
|
|
}
|
||
|
|
cout << endl;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
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);
|
||
|
|
}
|