initial checkin from subversion
This commit is contained in:
52
permutat1.cc
Normal file
52
permutat1.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
//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ü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);
|
||||
}
|
||||
Reference in New Issue
Block a user